日期:2014-05-19  浏览次数:20503 次

javascript读取XML文件
XML文件是这样的

<?xml   version= "1.0 "?>
<guestbook>
    <bt>
        <BOOY> 姓名 </BOOY>
        <XIN> 为淫民服务 </XIN>
        <LOU> 123456 </LOU>
        <DATE> 2006-10-27   14:26:51 </DATE>
        <ZKLZ> LZ </ZKLZ>
    </bt>
</guestbook>


怎 么才能实现在javascript读取

------解决方案--------------------
<script> var xml = " <?xml version=\ "1.0\ "?> <guestbook> <bt> <BOOY> 姓名 </BOOY> <XIN> 为淫民服务 </XIN> <LOU> 123456 </LOU> <DATE> 2006-10-27 14:26:51 </DATE> <ZKLZ> LZ </ZKLZ> </bt> </guestbook> "; var dom = new ActiveXObject( "MSXML2.DomDocument "); dom.loadXML(xml); var node = dom.selectSingleNode( "//BOOY "); if(node != null) { alert(node.text); } </script>
------解决方案--------------------
var xmlDoc = new ActiveXObject( "Msxml2.DOMDocument.4.0 ");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load( "C:\\temp\\books.xml ");