Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer here works for me. <a href="https://stackoverflow.com/a/13193743/366073">https://stackoverflow.com/a/13193743/366073</a> </p> <p>( See also: <a href="https://stackoverflow.com/a/43468/366073">https://stackoverflow.com/a/43468/366073</a> ) I will spend some time studying why this works, but assume we are iterating over nodes and then simply serializing them. </p> <p>To sum up the issue was not "extracting" the node, it was the approach to obtaining a string representation of the selection aka serialising it - that was wrong.</p> <p>Have tested using the snippet below in IE, FF &amp; Chrome and expected results obtained. Will now generalise this into our app. Have gone with the approach below &amp; is now working in our app... </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function serializeXmlNode(xmlNode) { if (typeof window.XMLSerializer != "undefined") { return new window.XMLSerializer().serializeToString(xmlNode); } else if (typeof xmlNode.xml != "undefined") { return xmlNode.xml; } return ""; } function hackit() { var data = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?&gt;" + "&lt;xml&gt;" + "&lt;ourStuff&gt;" + "&lt;blah a=\"x\" b=\"y\"&gt;" + "&lt;/blah&gt;" + "&lt;/ourStuff&gt;" + "&lt;thirdParty&gt;" + "&lt;blah a=\"0\" b=\"0\"&gt;" + "&lt;/blah&gt;" + "&lt;/thirdParty&gt;" + "&lt;/xml&gt;"; var xmlData = $.parseXML(data); var thirdPartyNode = $(xmlData).find("thirdParty blah")[0]; console.log(serializeXmlNode(thirdPartyNode)); var ourNode = $(xmlData).find("ourStuff blah")[0]; console.log(serializeXmlNode(ourNode)); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="hackit()"&gt; Loaded. &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload