xml2array

前端之家收集整理的这篇文章主要介绍了xml2array前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
http://www.oschina.net/action/project/go?id=15545&p=download

=========================================================
another XML parser:
=========================================================

<html>
<head>
<script type="text/javascript">
function parseXML()
{
var text="<note>";
text=text+"<to>Tove</to>";
text=text+"<from>Jani</from>";
text=text+"<heading>Reminder</heading>";
text=text+"<body>Don't forget me this weekend!</body>";
text=text+"</note>";
try
{// code for IE
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(text);
}
catch(e)
{// code for Mozilla,Firefox,Opera,etc.
try
{
var parser=new DOMParser();
var xmlDoc=parser.parseFromString(text,"text/xml");
}
catch(e)
{
alert(e.message);
return;
}
}
document.getElementByIdx_x("to").innerHTML=
xmlDoc.getElementsByTagName_r("to")[0].childNodes[0].nodeValue;
document.getElementByIdx_x("from").innerHTML=
xmlDoc.getElementsByTagName_r("from")[0].childNodes[0].nodeValue;
document.getElementByIdx_x("message").innerHTML=
xmlDoc.getElementsByTagName_r("body")[0].childNodes[0].nodeValue;
}
</script>
</head>

<body onload="parseXML()">
<h1>W3Schools Internal Note</h1>
<p><b>T</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
</p>
</body>
</html>

猜你在找的XML相关文章