How to read attribute in an XML rootnode using classic ASP?

lillieostrich

New Member
I am attempting to read the "ts" attribute in the rootnode of this XML, using classic ASP, but I cannot seem to get the proper syntax. I am able to read attributes in the various nodes and nested nodes below, but I need info from the rootnode.Can anyone suggest a solution?XML Code snippet:\[code\]<?xml version="1.0" encoding="utf-8"?><results ts="2012-04-24 17:10:45" nm="Test project" fin="0" bal="131494" vot="131494" tab="614" cltab="172" pol="1737" clpol="72" stpol="1735"> <choices> <choice id="1" tot="1" vot="211" e="1" /> <choice id="2" tot="1" vot="196" e="-1" /> </choices> <area id="1" bal="131494" vot="131494" bal2="131494" vot2="131494" tab="614" cltab="172" pol="1737" clpol="72" stpol="1735"> <tab> <cg cgId="1" tot="132" clos="131" /> <cg cgId="2" tot="23" clos="23" /> <cg cgId="3" tot="459" clos="18" /> </tab> </area> </areas></results>\[/code\]ASP Code Snippet to read a typical node that is working fine...\[code\]Dim objResultXMLSet objResultXML = Server.CreateObject("Microsoft.XMLDOM")objResultXML.async = FalseobjResultXML.Load (Server.MapPath("FileToParse.xml"))ReDim ResultArray(3,0)Set NodeList = objResultXML.documentElement.selectNodes("choices/choice")For Each Node In NodeList If CStr(ResultArray(0,0))<>"" Then ''< Balance signs ReDim Preserve ResultArray(3,UBound(ResultArray,2)+1) End if ResultArray(0,UBound(ResultArray,2)) =CLng(Node.getAttribute("id")) ResultArray(1,UBound(ResultArray,2)) =CLng(Node.getAttribute("tot")) ResultArray(2,UBound(ResultArray,2)) =CLng(Node.getAttribute("vot")) ResultArray(3,UBound(ResultArray,2)) =CStr(Node.getAttribute("e"))NextSet NodeList=Nothing\[/code\]
 
Back
Top