I am using MSXMl library to parse xml
after I call put_text and then get_xml
the output will have < & > converted to <
& >
How can i get rid of this?
I am using MSXMl library to parse xml
after I call put_text and then get_xml
the output will have < & > converted to <
& >
How can i get rid of this?
< and > are prohibited to use inside the text and need to be encoded as > and <. The only way to avoid this is creating a CDATA section for the text containing those. But you really don't need to if you intend to read the XMLT with MS XML - it will decode those symbols just fine and you will get your < and > perfectly fine in the extracted text.
Are you getting <
or <
?
There should be a semi-colon on the end of them to be a valid entity.
Well you are converting from plain text to XML encoded text.
This is the behavior I would expect.
If you want the original string you put in try converting back to text with get_text().
If you do not want the put_text() to encode the text without encoding the < and > then it must be inside a CData section.
<![CDATA[ Text that can include < and > without encoding ]]>
If if you want it to be included as text its fine that it is escaped. Each xml pareser will back escape the text.
If you want it as xml elements you can not create them using put_text but need to create the tree this way
dataNode=xmlDoc.createElement("data")
idNode=xmlDoc.createElement("id")
textNode=xmlDoc.createTextNode("17")
idNode.appendChild(textNode)
nameNode=xmlDoc.createElement("name")
textNode=xmlDoc.createTextNode("Uday")
nameNode.appendChild(textNode)
...
dataNode.appendChild(idNode)
dataNode.appendChild(nameNode)
...
parentNode.appendChild(dataNode)
what might looker better if you look with the eye and want the text be written on the file you may use cdata section.
newCDATA=xmlDoc.createCDATASection("<data><id>17</id>...</data>")
parentNode.appendChild(newCDATA)