Use $msgXML.childNodes
to get this work in all browsers.
jQuery - works in Firefox - returns Undefined in IE & Chrome
-
29-05-2022 - |
Question
I have the following XML that I am using in several functions in a web page that uses jQuery.
var msgXML = "<XMLInput><Source></Source><MessageText></MessageText><SendTime></SendTime><Destination></Destination></XMLInput>",
msgXMLDoc = $.parseXML(msgXML),
$msgXML = $( msgXMLDoc );
In a function that makes use of the above in order to set values, as shown below:
$msgXML.find("Source").append(newSource);
$msgXML.find("MessageText").append(NewMessageTxt);
$msgXML.find("SendTime").append(currDateTime);
$msgXML.find("Destination").append(newDest);
var newXML = $msgXML.children(0).get(0).outerHTML;
The last line above sets newXML with the outerHTML that I am then passing into another function (to write it into a table).
In Firefox, the last line works fine & a console.log of newXML
shows the XML I expected to see. However, in both IE and Chrome, it returns Undefined. What do you need to do to be able to use the XML data that is in outerHTML in all 3 browsers?
Thanks!
No correct solution
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow