Shane
Shane

Reputation: 5151

log DOM view of XML in firebug?

I'm trying to send an XML node to the firebug console and when calling something like

console.log(myXML);

I see something like the below in the output panel

constructor     XML Document {}

expanding this takes me to a list of the XML DOM methods, etc, not the document itself. I was hoping there was a way to trace out a DOM view of the node, similar to when you call console.log on an html element. Am I doing something wrong or is this not possible?

Thanks,

Upvotes: 4

Views: 1700

Answers (1)

Wayne
Wayne

Reputation: 60424

This works on XML elements, just not on the document itself. Try this:

var parser = new DOMParser();
var doc = parser.parseFromString("<test></test>", "text/xml");  
console.log(doc.firstChild);

To print an outline from the document element, use the following:

console.dirxml(doc)

Upvotes: 2

Related Questions