Sign in to follow this  
Followers 0
benners

XML parsing using _XMLGetAllAttribIndex

3 posts in this topic

HI

I am trying to retrieve information from a .mum file which seems to be a renamed xml file. I have used the _XMLGetAllAttribIndex successfully before on other xml files but I cannot get this simple code to work.

I really only want to read the attributes under the assemblyIdentity but when it wouldn't work I went as simple as I could and figured I could just add to the XPath. below is the code and attached is the mum file.(renamed to xml to enable upload)

I thought it might be that the namespace needed specifying for the xml structure but when I added it to the $strNameSpc variable there were errors about only having one hyphen. Hopefully it is a simple solution and not one that doesn't make me feel to stupid :

#include 'V:\XPDVD\AutoIt\Another OI\User UDFs\_XMLDomWrapper.au3'
#include <array.au3>

Local $hFile = _xmlFileOpen(@scriptdir & '\update.num')
If @error Then MsgBox(0, 'oops', @error)

Local $aValues
$aValues = _XMLGetAllAttribIndex('/assembly')
If @error Then MsgBox(0, '', $aValues)

_ArrayDisplay($aValues)

Thanks

update.xml

Share this post


Link to post
Share on other sites



here you go:

$file = @DesktopDir & "\update.xml"
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.Load($file)

$oAssembly = $oXML.selectSingleNode("//assembly")
;~ ConsoleWrite($oAssembly.xml)

$oAttributes = $oAssembly.attributes
For $oAttribute In $oAttributes
    ConsoleWrite($oAttribute.xml & @CRLF & @TAB & $oAttribute.nodename & @CRLF & @TAB & $oAttribute.value & @CRLF)
Next

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks for the code.

After looking at what you had coded I looked through the _XMLDomWrapper.au3 code and functions and started checking where the errors happened. To cut 3 hours short I found that when XPath was selected as the 'SelectionLanguage' and the version of msxml was selected as 3 I got the results I wanted and all the other functions I tried produced expected returns.

By default, if no version of msxml is specified all the versions from 8 down are tried until an object is created. Mine was v6.0. The SelectionLanguage is set as XPath for all versions but for some reason errors were produced with this property changed from the default (XLSPattern).

I edited some code from

$objDoc.setProperty("SelectionLanguage", 'XPath')

to

If $iver <> 3 then $objDoc.setProperty("SelectionLanguage", 'XPath')

and it works.

Thanks again

Share this post


Link to post
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
Sign in to follow this  
Followers 0