html文件:
<html>
<head>
<script type="text/javascript">
function parseXML()
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject("microsoft.xmldom");
alert('ie');
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
alert('ff');
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.async=false;
xmlDoc.load("class.xml");
var val=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
alert(val);
}
</script>
</head>
<body onload="parseXML()">
</body>
</html>
class.xml
<?xml version="1.0" encoding="utf-8"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。