Edward Tanguay
Edward Tanguay

Reputation: 193372

Is there a way to define multiline XML in code in C# without having to change " to ""?

I would like to be able to paste chunks of XML into my C# code.

However, the best I can do is the following, but then I have to search and replace " with "".

Is there a way to define multiline XML in C# code without having to alter the XML text like this?

        public static string GetXml1()
        {
            return @"
<Customer>
  <FirstName status=""required"">Jim</FirstName>
  <LastName status=""required"">Smith</LastName>
</Customer>
";
        }

Upvotes: 1

Views: 3096

Answers (2)

AnthonyWJones
AnthonyWJones

Reputation: 189505

Store the XML as a string resource then retrieve the XML as using ResourceManager.

Upvotes: 5

erikric
erikric

Reputation: 4169

Not necessarily what you are askin for, but Box/Column Select might help if the lines are alligned. Just hold down the 'Alt'-key while you use the mouse to select the " you want to remove and press delete.

Upvotes: 0

Related Questions