ChristianJ Posted October 30, 2013 Posted October 30, 2013 Hi. I'm an AutoIT beginner and trying to use the "XMLDomWrapper". My test XML: <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> </book> <book id="bk102"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> </book> <book id="bk103"> <author>Corets, Eva</author> <title>Maeve Ascendant</title> <genre>Fantasy</genre> <price>5.95</price> </book> <book id="bk104"> <author>Corets, Eva</author> <title>Oberon's Legacy</title> <genre>Fantasy</genre> <price>5.95</price> </book> </catalog> Currently I'm going to each "<book>" and read the <"id> (e.g. "bk101" for the first). Now I need the "<title>" of each book. How can I get this? My script (simplified): Local $strXML Local $strXMLStructure Local $strID Local $strTitle $strXMLStructure = "/catalog/book" $strXML = _XMLFileOpen("X:\MyXML.xml") For $intI = 1 To _XMLGetNodeCount($strXMLStructure) $strID = _XMLGetAttrib($strXMLStructure & "[" & $intI & "]", "id") ConsoleWrite("ID: " & $strID & @LF) $strTitle = ??? ConsoleWrite("Title: " & $strTitle & @LF) Next The "???" marks the position where I need you help! Thanks in advance, Chris
jdelaney Posted October 30, 2013 Posted October 30, 2013 love me some xml: $strXMLStructure = "//catalog/book" $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir & "\some.xml") $oBooks = $oXML.selectNodes($strXMLStructure) For $oBook In $oBooks $oID = $oBook.getAttribute("id") $oAuthor = $oBook.selectSingleNode("./author") $oTitle = $oBook.selectSingleNode("./title") $oGenre = $oBook.selectSingleNode("./genre") $oPrice = $oBook.selectSingleNode("./price") ConsoleWrite($oID & @TAB & $oAuthor.text & @TAB & $oTitle.text & @TAB & $oGenre.text & @TAB& $oPrice.text & @TAB & @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.
ChristianJ Posted October 30, 2013 Author Posted October 30, 2013 Hi jdelaney, your solution without the XMLDomWrapper seems to be easier. Thank you very much!
jdelaney Posted October 30, 2013 Posted October 30, 2013 They do the same thing, behind the scenes, but the direct calls will not do error handling/validating...which can be written in. I just never took the time to learn the UDF. IsObj will be your friend. 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.
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