chenxu Posted September 27, 2008 Share Posted September 27, 2008 CODE<?xml version="1.0" ?> <menu> <item name="item 1" exe="d:\test1.exe" arg="aaa, bbb"/> <item name="item 2" exe="d:\test2.exe" arg="aaa, bbb"/> <item name="item 3" exe="d:\test3.exe" arg="aaa, bbb"/> <item name="item 4" exe="d:\test4.exe" arg="aaa, bbb"/> <item name="item 5" exe="d:\test5.exe" arg="aaa, bbb"/> </menu> I don't kown how to get all items with _XMLDomWrapper.au3, I still can't do what I want after search the forum, help me please, give me any advice or example code Link to comment Share on other sites More sharing options...
Marlo Posted September 27, 2008 Share Posted September 27, 2008 look for _XMLWrapper Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
bluelamp Posted September 27, 2008 Share Posted September 27, 2008 (edited) Ok, I tried to read your xml with this UDF.I think it can´t be done because this UDF assumes that your nodes have different names.Here is my testcode:#include <_XMLDomWrapper.au3> #Include <Array.au3> Const $file = "file.xml" If _XMLFileOpen($file,"",-1) == -1 Then ConsoleWrite("can´t open file!"&@CRLF) Exit EndIf $array = _XMLGetChildNodes("/menu") _ArrayDisplay($array) For $i=1 To $array[0] ConsoleWrite(_XMLGetAttrib($array[$i],"name")&@CRLF) NextLook at this -> #544372 Edited September 27, 2008 by bluelamp Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 27, 2008 Share Posted September 27, 2008 Ok, I tried to read your xml with this UDF. I think it can´t be done because this UDF assumes that your nodes have different names. Not true. It is very common to have multiple items with the same tag ("item" in this case), and they are then addressed by 1-based instance in the path used. From the example XML file, "/menu/item[2]" would address the second instance: #include <_XMLDOMWrapper.au3> ; Open file $sXML = "Test_1.xml" If _XMLFileOpen($sXML,"",-1) = -1 Then ConsoleWrite("can´t open file!" & @CRLF) Exit EndIf ; Get count of item nodes in menu $iItems = _XMLGetNodeCount("/menu/item") ConsoleWrite("$iItems = " & $iItems & @LF) ; List the "name" attribute of each item For $i = 1 To $iItems ConsoleWrite(_XMLGetAttrib("/menu/item[" & $i & "]","name") & @CRLF) Next Google up the details of XML Path (or XPath) syntax for more details. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now