2012-04-25 6 views
2

従来のASPを使用して、このXMLのルートノードの "ts"属性を読み取ろうとしていますが、適切な構文が得られないようです。私は下の様々なノードとネストされたノードの属性を読み取ることができますが、ルートノードからの情報が必要です。古典的なASPを使用してXMLルートノードの属性を読み取る方法は?

誰も解決策を提案できますか?

XMLコードスニペット:

<?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> 

ASPコードスニペットを正常に動作している典型的なノードを読むために...

Dim objResultXML 
Set objResultXML = Server.CreateObject("Microsoft.XMLDOM") 
objResultXML.async = False 
objResultXML.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")) 

Next 
Set NodeList=Nothing 

答えて

5

.documentElementresults要素です。

必要なのはそういうことだ:objResultXML.documentElement.getAttribute("ts")

+0

はどうもありがとうございました! – daveo

関連する問題