Jump to content

Microsoft.XMLDOM selectSingleNode problem


gykisz
 Share

Recommended Posts

Hi Guys,

I would need the value of i4 from the attached xml file, but the selectSingleNode doesn't work for me.
Help, pls.
 
#include <Array.au3>

Enum $iData_NodeName, $iData_AttributeName, $iData_AttributeValue, $iData_UBound

$oXML = ObjCreate("Microsoft.XMLDOM")

If Not IsObj($oXML) Then
    MsgBox(0, "", "Unable to create COM session to XML.")
    Exit
EndIf

$oXML.Load(@ScriptDir & "\teszt.xml")

$oParent = $oXML.selectSingleNode('//methodResponse/params/param/value/struct/member[name =""Id""]/value/i4')

$aData = ""

$i = 0

For $oChild In $oParent.childNodes
    For $oAttribute In $oChild.attributes
        If IsArray($aData) Then
            ReDim $aData[UBound($aData) + 1][$iData_UBound]
        Else
            Local $aData[1][$iData_UBound]
        EndIf
        $aData[UBound($aData) - 1][$iData_NodeName] = $oChild.nodename
        $aData[UBound($aData) - 1][$iData_AttributeName] = $oAttribute.nodename
        $aData[UBound($aData) - 1][$iData_AttributeValue] = $oAttribute.text
        ConsoleWrite("NodeName=[" & $oChild.nodename & "]: AttributeName=[" & $oAttribute.nodename & "] AttributeValue=[" & $oAttribute.text & "]" & @CRLF)
    Next
    $i += 1
Next
_ArrayDisplay($aData, $i)

 

teszt.xml

Link to comment
Share on other sites

Try this :

$oXML = ObjCreate("Microsoft.XMLDOM")
If Not IsObj($oXML) Then Exit MsgBox(0, "", "Unable to create COM session to XML.")
$oXML.Load("teszt.xml")
$oParent = $oXML.selectSingleNode('//struct/member[name="id"]/value/i4')
MsgBox ($MB_SYSTEMMODAL, "", $oParent.text)

 

Edited by Nine
Link to comment
Share on other sites

Thank you, guys!

Both solutions work great. Just another question, @Nine. This xml file is a result of an http query, but if I use it this way: $oXML.Load = $XmlHttp.responsetext, then it doesn't work. What could be the reason for this?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...