I'm using jQuery Ajax to retrieve an XML document from the server which I then want to transform into HTML and inject into the browser DOM. I'm retrieving it using dataType:'xml' so it's wrapped as an XML document rather than HTML. This allows me to do the manipulation I want to do before insertion.
However, I can't find a way to insert the manipulated xml into the DOM:
$('#myContainer').append(myXML)
causes a security violation in IE and has no effect in Firefox, while
$('#myContainer').append(myXML[0].xml)
works in IE but not Firefox (the xml property appears to be non-standard)
myXML.text() returns only the text nodes from the XML, and not the markup, while myXML.html() returns null.
I've also tried retrieving it as text, which allows me to create a "standard" jQuery object which inserts just fine. However, I have the following sort of thing going on:
<div><input type='checkbox'><otherElement/></input></div>
and want to modify the input element based on the contents of otherElement. If I recover the original xml as text, jQuery reduces it to
<div><input type='checkbox'><otherElement/></div>
so that the parent element of otherElement is the div and not the input, making manipulation of the input element unreliable. The same occurs if I retrieve it as html.
Any suggestions much appreciated.