Asp classic 无法从asp文件中的xml获取属性
我一直在尝试从以下xml中获取一个属性Asp classic 无法从asp文件中的xml获取属性,asp-classic,Asp Classic,我一直在尝试从以下xml中获取一个属性 <getAtt MapReady="0" QueryTime="0" t="17" tt="15" pcheck="1" Startval="1" AutoNextStres="171" TC="171" q=+(A%3a(64))+AND+C%3a0+AND+((((BODY%3asujit)+OR+(BODY%3asujit*))+AND++(+(ICAL3%3a1+)+AND+(+(ICAL4%3a1+)+OR+(ICAL4%3a3+)+OR+
<getAtt MapReady="0" QueryTime="0" t="17" tt="15" pcheck="1" Startval="1" AutoNextStres="171" TC="171" q=+(A%3a(64))+AND+C%3a0+AND+((((BODY%3asujit)+OR+(BODY%3asujit*))+AND++(+(ICAL3%3a1+)+AND+(+(ICAL4%3a1+)+OR+(ICAL4%3a3+)+OR+(ICAL4%3a6+)++)++)))&start=1&rows=40" LogID="1664" ErrorCode=""></<getAtt>
从指定的xml中,我必须获取t属性。此xml保存在asp文件中的变量中。请建议我立即获取。有两种方法 您可以手动拆分字符串并手动解析它,或者,您可以使用第三方XML解析器,例如-我建议使用后者 首先,您需要准备getAtt节点作为一个基本的XML文档,并带有相关的父节点等。您需要的主要内容是一个根节点,然后在MSXML2中打开该XML文档。一旦打开,您就可以设置根目录并通过其中的每个getAtt节点进行循环 以下是一个例子:
<%
''#### Define the XML to parse
dim TestXML, oXML, oNode, sValue
TestXML = TestXML & "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbcrlf
TestXML = TestXML & "<wrapperNode>" & vbcrlf
TestXML = TestXML & "<getAtt MapReady=""0"" QueryTime=""0"" t=""17"" tt=""15"" pcheck=""1"" Startval=""1""></getAtt>" & vbcrlf
TestXML = TestXML & "</wrapperNode>" & vbcrlf
''#### Ready the XML Parser
Set oXML = Server.CreateObject("Msxml2.DOMDocument.6.0")
''#### Load the XML
oXML.LoadXML(TestXML)
''#### Set the root (so we can easily get a collection of nodes)
Set oRoot = oXML.selectSingleNode("//wrapperNode")
''#### Loop through each node and echo out the value of the "t" attribute
For Each oNode In oRoot.childNodes
response.Write oNode.Attributes.getNamedItem("t").Text
Next
''#### Cleanup
Set oXML = Nothing
%>
为什么是.Attributes.getNamedItemt.Text而不是更简单、更标准的.getAttributet?