asp解析xml文件输出到页面
color.xml
<?xml version= "1.0 " encoding= "gb2312 "?>
<colors>
<game type= "1 " color= "#CC6600 "/>
<game type= "2 " color= "#FFE000 "/>
<game type= "3 " color= "#339999 "/>
<game type= "4 " color= "#990000 "/>
<game type= "5 " color= "#C94F1B "/>
</colors>
用asp如何解析??
------解决方案-------------------- <%
Set d = Server.CreateObject( "Msxml2.DOMDOcument ")
d.async = false
d.load Server.MapPath( "a.xml ")
Set nodes = d.selectNodes( "/colors/game ")
For Each node In nodes
Response.Write " <li> " & node.nodeName & " = " & node.Attributes(0).value & " " & node.Attributes(1).value
Next
%>
------解决方案--------------------Set strC = objXML.selectSingleNode( "/colors/game[@type = '世界杯 ']/@color ")
Response.write strC.Value
试下罗,不过不抱希望asp会支持直接定位到属性的xpath
还可以试下先取到/colors/game[@type = '世界杯 '],然后取这个game节点的color属性
至于你原来那个/colors/game/color[../type = '世界杯 '],我还真不知道这是什么东东