How can I convert xml to a string in IE?



I am using this function that I found on SO



function serializeXmlNode(xmlNode) {
if (typeof window.XMLSerializer != "undefined") {
return (new window.XMLSerializer()).serializeToString(xmlNode);
} else if (typeof xmlNode.xml != "undefined") {
return xmlNode.xml;
}
return "";
}


I tried using it in my code here:



var doc = parser.parseFromString(mattes_get_mattes_xml(), "application/xml"); //convert the string to xml
doc.getElementsByTagName('fillet')[index].innerHTML = "<imgsrc>" + thumb + "</imgsrc><width>" + width + "</width><cid>" + cid + "</cid><sku>" + sku + "</sku>";
console.log(doc.getElementsByTagName('fillet')[index].innerHTML);
//var serializer = new XMLSerializer(); //create a new XMLSerializer

//mattes_mattes_xml = serializer.serializeToString(doc); //convert the xml back to a string
mattes_mattes_xml = serializeXmlNode(doc);
console.log(mattes_mattes_xml);
common_get_order_xml();
moulding_draw(img, "fillet", selected_matte); //Call the moulding_draw function, which draws the fillet on the canvas


My first output of console.log(doc.getElementsByTagName('fillet')[index].innerHTML); gives me <imgsrc>113a2584b32539ecdc35d70b39fde504</imgsrc><width>0.31</width><cid>9352</cid><sku>TD00060S1</sku>.


The second output of console.log(mattes_mattes_xml); gives me <Mats><mat><item size="0"><imgsrc>478374fede4b2625708c5b4f71fb5e53</imgsrc><size>0</size><cpu>20</cpu><cid>4180</cid></item><fillet /></mat><mat><item size="0.5"><imgsrc>3a546c35f4fc21a748769e1f15bcdac5</imgsrc><size>0.5</size><cpu>0</cpu><cid>4460</cid></item><fillet /></mat><mat><item size="0.5"><imgsrc>556e832bb85e3887c3597a67defbb100</imgsrc><size>0.5</size><cpu>0</cpu><cid>4117</cid></item><fillet /></mat></Mats> - it is missing the stuff inside of <fillet>


IE version is 11.


No comments:

Post a Comment