I have read an XML file and converted into NSXMLDocument object. But, due to the presence of "<" in the string content of a node, it has been converted into "<". So, when i write it as xml document to a file, it has the character "<" in it.
How can i write to the file as ordinary XML file in which "<" will be replaced by "<".
Thanks and Regards, Lenin
When the <
character appears in a text node, it will be serialized as <
when you write your xml to a file.
When you later read that file with an xml parser, the text node will contain the original <
character.
You also have the option of CDATA encoding the text node. In this case the serialized character is <
inside a CDATA block. Many XML APIs will not retain any difference between CDATA and text nodes. CDATA should be thought of as an escaping mechanism to make editing easy for human authors.
The <
in text nodes of an xml should be represented as <
.
If you replace it using s/</</g
before writing it to the xml file, it will lead to parsing error when you read from that file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With