I have an XML data source that has HTML & CSS formatted data contained in one of the document nodes. What is the proper way to escape this data so that I can properly parse it? For clarification, I am using TouchXML in Objective-C to parse the data. (Not that it should matter but I wanted to include all pertinent information.)
Any help would be much appreciated. Thank you!
L.
I'm assuming you have XML data that will have nodes containing HTML markup, not a mixture of XHTML and XML data intertwined in your document.
In this case, I generally prefer to use CDATA blocks for HTML data. This allows you to put any HTML you want. Trying to add HTML as regular nodes in an XML document can cause problems due to the fact that it is not always 100% XML compliant, as well as the fact that character entities would need to be defined in order to be properly recognized by an XML parser.
<xmlNode>
<![CDATA[
<Any>
<Html>
<Tags>
<You>
<Want />
</You>
</Tags>
</Html>
</Any>
]]>
<xmlNode>