跪求~~~浏览器不同解析XML文件

来源:百度知道 编辑:UC知道 时间:2024/05/24 07:02:08
<categories>
<category>
<id>60</id>
<name>
<![CDATA[ Home Supplies]]>
</name>
<unionNames>
<![CDATA[ Home Supplies]]>
</unionNames>
<isLeaf>false</isLeaf>
<itemCount>0</itemCount>
</category>
<category>
<id>280</id>
<name>
<![CDATA[ Baby & Children's]]>
</name>
<unionNames>
<![CDATA[ Baby & Children's]]>
</unionNames>
<isLeaf>false</isLeaf>
<itemCount>0</itemCount>
</category>
<category>
<id>300</id>
<name>
<![CDATA[ Agriculture & Food]]>
</name>
<unionNames>
<![CDATA[ Agriculture & Food]]>
</unionNames>
<isLeaf>false</isLeaf>
<itemCount>0</item

LZ是要把这个文件直接显示在IE中吗?还是在IE中用javascript解析?以下代码在IE6中测试通过:
<script language="javascript">
document.writeln("<table border=1>");
var xml=new ActiveXObject('Microsoft.XMLDOM');
xml.load("test.xml");
var categories=xml.documentElement.selectNodes("/categories/category");
for (var i=0;i<categories.length;i++)
{
document.writeln("<tr>");
var id=categories[i].firstChild;
var idValue=id.firstChild.nodeValue;
document.writeln("<td>"+idValue+"</td>");

var name=categories[i].selectSingleNode("name");
var nameValue=name.firstChild.nodeValue;
document.writeln("<td>"+nameValue+"</td>");

var unionNames=categories[i].selectSingleNode("unionNames");
var unionNamesValue=unionNames.firstChild.nodeValue;
document.writeln("<td>&q