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!

没有正确的解决方案

其他提示

Use $msgXML.childNodes to get this work in all browsers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top