Posted By: Anonymous
I am working with some XML that holds strings like:
<node>This is a string</node>
Some of the strings that I am passing to the nodes will have characters like
<node>This is a string & so is this</node>
This is not valid due to
I cannot wrap these strings in CDATA as they need to be as they are. I tried looking for a list of characters that cannot be put in XML nodes without being in a CDATA.
Can someone point me in the direction of one or provide me with a list of illegal characters?
The only illegal characters are
> (as well as
' in attributes, depending on which character is used to delimit the attribute value:
attr="must use " here, ' is allowed" and
attr='must use ' here, " is allowed').
They’re escaped using XML entities, in this case you want
Really, though, you should use a tool or library that writes XML for you and abstracts this kind of thing away for you so you don’t have to worry about it.