CreateTextNode escape characters in large text string



I am trying to include the correct characters in an XML document text node:



request.appendChild(doc.createTextNode(xml));


The xml string is a segment of a large xml file which I have read in:



<firstname>John</firstname>
<dateOfBirth>28091999</dateOfBirth>
<surname>Doe</surname>


The problem is that passing this into createTextNode is replacing some of the charters:



&lt;firstname&gt;John&lt;/firstname&gt;&#13;
&lt;dateOfBirth&gt;28091999&lt;/dateOfBirth&gt;&#13;
&lt;surname&gt;Doe&lt;/surname&gt;&#13;


Is there any way I can keep the correct characters (< , >) in the textnode. I have read about using importnode but this is not correctly XML, only a segment of a file.


Any help would be greatly appreciated.


No comments:

Post a Comment