2012-11-22 7 views
0
I`ve가 XML 별개의 속성 값을 얻기 위해 노력하고

가 별개의 특성을 얻기 :XML 노드

for i=0 xmlOx.selectNodes("a").length-1 
arr(i)=xmlOx(i).selectNodes("a").getAttribute("x") 
next 

처럼, 여기에 내가 t duplicates.Then 필요 ve to get "x" attribute values but I don 나는 VBScript를의 배열에 값을 추가해야합니다.

우리가 어떻게하는지 말해 주시겠습니까?

답변

0

이론은 here입니다.

코드 :

Dim sXml : sXml = Join(Array(_ 
     "<root>" _ 
    , "<a x=""Animal"" y=""Bird""/>" _ 
    , "<a x=""Animal"" y=""Bird""/>" _ 
    , "<a x=""Country"" y=""Bird""/>" _ 
    , "<a x=""Animal"" y=""Bird""/>" _ 
    , "</root>" _ 
)) 
    Dim oXDoc : Set oXDoc = CreateObject("Msxml2.DOMDocument") 
    oXDoc.loadXml sXml 
    WScript.Echo oXDoc.xml 

    Dim xObjXml : Set xObjXml = oXDoc.documentElement.childNodes 
    Dim dicAttrs : Set dicAttrs = CreateObject("Scripting.Dictionary") 
    Dim i 
    For i = 0 To xObjXml.length - 1 
     Dim a : a = xObjXml(i).getAttribute("x") 
     dicAttrs(a) = dicAttrs(a) + 1 
    Next 
    Dim aAttrs : aAttrs = dicAttrs.Keys() 
    WScript.Echo Join(aAttrs) 

출력 : answer.Please이 게시물에 내 업데이 트를 확인하고 please.Use 정확한 변수를 회신에 대한

<root> 
     <a x="Animal" y="Bird"/> 
     <a x="Animal" y="Bird"/> 
     <a x="Country" y="Bird"/> 
     <a x="Animal" y="Bird"/> 
</root> 

Animal Country 
+0

감사합니다. – user1495475

+0

@ user1495475 - 죄송합니다. 코드 조각이 의미가 없기 때문에 그렇게 할 수 없습니다. –

+0

나는 모든 코드를 넣을 수 없으므로 임의의 xml을 넣었습니다. 도와 주실 수 있는지 확인하십시오. – user1495475