我有一个包含节点和属性的XML文件。我使用传统的ASP访问和接收来自XML的数据。但是XML文件具有一些我应该在屏幕上打印的属性。访问XML属性
XML文件是一样的东西
<root>
<product>
<node1>Node1 Value</node1>
<node2>Node2 Value</node2>
<attribute value="category">Category Name</attribute>
</product>
</root>
而且我这个脚本
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
objXMLDoc.async = True
objXMLDoc.load Server.MapPath("ProductList3.xml")
Dim xmlProduct
For Each xmlProduct In objXMLDoc.documentElement.selectNodes("product")
Dim node1 : node1 = xmlProduct.selectSingleNode("node1").text
Dim node2 : node2 = xmlProduct.selectSingleNode("node2").text
Response.Write "<b>node1:</b>" & Server.HTMLEncode(node1) & "<br> "
Response.Write "<b>node2:</b>" & Server.HTMLEncode(node2) & "<br>" %>
Next
我没有访问节点的任何问题,接收数据,但我需要得到属性值“类别”,所以我想是这样
Dim category : Set category = getText(xmlProduct.SelectNodes("root/product/attribute value[@name='category']")
,但我接受")" required in line 52 error (err no:800a03ee)
。
Set category= getText(xmlProduct.SelectNodes("root/attribute value[@name='Category']")
我得在该属性的类别名称,但无法找到任何解决方案,也许我是完全错误的管线52你们可以帮我解决这个问题?
XML中没有名为'urun'的节点。请仔细检查您的示例代码是否与您的示例输入文档匹配。 – Tomalak
编辑。谢谢。 –