How to escape the character entities in XML?
- by Chetan Vaity
I want to pass XML as a string in an XML attribute.
<activity evt="<FHS>
<act>
<polyline penWidth="2" points="256,435 257,432 "/>
</act>
</FHS> />
Here the "evt" attribute is the XML string, so escaping all the less-than, greater-than, etc characters by the appropriate character entities works fine.
The problem is I want a fragment to be interpreted as is - the character entities themselves should be treated as simple strings.
When the "evt" attribute is read and an XML is generated from it, it should look like
<FHS>
<act>
<polyline penWidth="2" points="256,435 257,432 "/>
</act>
</FHS>
Essentially, I want to escape the character entities. How is this possible?