I tried writing some XML that has a line like:
<node attr="{foo}"/>
and loading it in C#, and getting:
System.Xml.XmlException: Name cannot begin with the '{' character, hexadecimal value 0x7B. Line 2, position 14.
I tried escaping with {
, but that just gives:
System.Xml.XmlException: Name cannot begin with the '&' character, hexadecimal value 0x26. Line 2, position 14.
(I'm no expert on XML, and I had thought I didn't need to escape anything in an attribute except "
. I tried looking on google and SO, and didn't find anything obvious. I even tried looking in the XML spec, but everything there is so ridiculously abstract and generic I can't actually tell when I have to escape something, or how to escape it.)
What characters do I have to escape in an XML attribute value? And how exactly do I escape them?