How to get the innerHTML of a XML document (AJAX)?

Posted by JCOC611 on Stack Overflow See other posts from Stack Overflow or by JCOC611
Published on 2011-01-07T21:48:28Z Indexed on 2011/01/07 21:53 UTC
Read the original article Hit count: 132

Filed under:
|
|

After an AJAX query, a XML file is returned. I'm able to "parse" that file, but when it comes to getting the "innerHTML" (or in this case "innerXML" lol) of an element, I fail.

If the XML element, let's say "content", only contained text I could do: content.childNodes[0].nodeValue (assuming that content references the XML element "content"). But that element contains other elements:

<stackoverflow reason="tribute to this page">
   <content>
      <div><span><p>Some more HTML elements</p></span></div>
   </content>
</stackoverflow>

I need to copy the content of <content> to an existing <div> in the page, how could I do that?

Ex. myDiv.innerHTML = content.innerHTML;

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about Xml