Skip to content Skip to sidebar Skip to footer

Get Xml Document In Chrome Via JS

After I open an Xml document in Chrome, I want to get the XML source in console via js. But document object seems to be an HTML document. So How can I get the real Xml and is ther

Solution 1:

XML is just data, it's not a representation of a textual or graphical document like HTML is. So when you load an XML document into Chrome, it synthesizes an HTML document that displays the XML DOM as text.

However, it stashes the original XML DOM in an element of the page:

<div id="webkit-xml-viewer-source-xml">
    ... XML DOM is here
</div>

So if document.getElementById("webkit-xml-viewer-source-xml") returns an element, the document was originally XML. You can then use this element's .innerHTML property to get the XML as text.


Post a Comment for "Get Xml Document In Chrome Via JS"