views:

454

answers:

4

Is there an escape character for a quote in xml? I want to write a tag like:

<parameter name="Quote = " ">

but if I put ", then that means string has ended. I need something like this (c++):

printf("Quote = \" ");

Is there a character to write before the quote to escape it?

+6  A: 

Try this:

&quot;
Andrew Hare
+1  A: 

No there isn't an escape character as such, instead you can use &quot; or even <![CDATA["]]> to represent the " character.

Matt Howells
+9  A: 

Others have answered in terms of how to handle the specific escaping in this case.

A broader answer is not to try to do it yourself. Use an XML API - there are plenty available for just about every modern programming platform in existence.

XML APIs will handle things like this for you automatically, making it a lot harder to go wrong. Unless you're writing an XML API yourself, you should rarely need to worry about the details like this.

Jon Skeet
+1 This is _very_ valuable advice and ought to be heeded.
Andrew Hare