Quantcast
Channel: Print xml in javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Print xml in javascript

$
0
0

I tryed to use answer from How to print pretty xml in javascript? but it didnt work for my code. It prints [object]. Is there some way to print xml in this object?

<!DOCTYPE html>
<html>
<head>
<script src="loadxmldoc.js"></script>
</head>
<body>

<script>

var xmldoc= loadXMLDoc('skoly.xml');

var d = document.createElement('div'); 
var t = document.createTextNode(xmldoc); 
d.appendChild(t);
document.write('<pre>' + d.innerHTML + '</pre>');


</script>
</body>
</html>

loadxmldoc.js:

function loadXMLDoc(filename)
{
if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else // code for IE5 and IE6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
}

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images