I am trying to inspect an xml file in the console in IE11. In every other browser, all I have to do is add the line console.log(myXML);
and it will output the raw xml in the console. However, the same code will output an object representation with all its properties in IE11 and Edge. I just want to see the xml just like it's displayed in all other browsers. How do I acplish this? And why the heck would IE do it differently than other browsers in the first place?
I am trying to inspect an xml file in the console in IE11. In every other browser, all I have to do is add the line console.log(myXML);
and it will output the raw xml in the console. However, the same code will output an object representation with all its properties in IE11 and Edge. I just want to see the xml just like it's displayed in all other browsers. How do I acplish this? And why the heck would IE do it differently than other browsers in the first place?
-
Try using string formatting:
console.log('%s',myXML);
– hindmost Commented Jul 6, 2017 at 16:20
2 Answers
Reset to default 5Use the dirxml
method.
Per the official documentation found here: https://msdn.microsoft./en-us/library/dn265067(v=vs.85).aspx
Dirxml: Logs an XML node object to the console.
var parser = new DOMParser();
var xml = parser.parseFromString("<books isbn=\"1111\"><book><title>Hello world!</title></book></books>", "application/xml");
console.dirxml(xml);
Have you tried using the XMLSerializer?
var myXMLstring = new XMLSerializer().serializeToString(myXml)
console.log(myXMLstring)