Posted on 2009-09-10 21:22
S.l.e!ep.¢% 阅读(134)
评论(0) 编辑 收藏 引用 所属分类:
HTML
<script>
function analyzeXML(strXml)
{
var objXMLDoc = new ActiveXObject("MSXML.DOMDocument");
strXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
strXml += "<Test>";
strXml += "<Test1>";
strXml += "<Test2>abc</Test2>";
strXml += "</Test1>";
strXml += "</Test>";
objXMLDoc.async = false;
if( objXMLDoc.loadXML(strXml) )
{
//
alert( objXMLDoc.selectNodes("Test/Test1/Test2").length );
alert( objXMLDoc.selectNodes("Test/Test1/Test2")(0).text );
}
else
{
//
alert( "Failed to Load Xml!" );
}
}
analyzeXML("");
</script>