Kyan Posted April 29, 2015 Share Posted April 29, 2015 (edited) Hi, this piece of non-sense doesn't even gives an xml file as example https://msdn.microsoft.com/en-us/library/ms754523(v=vs.85).aspxHow do I call and retrieve all the matches node?<?xml version="1.0"?> <!DOCTYPE compactdiscs SYSTEM "cds.dtd"> <compactdiscs> <compactdisc> <artist type="individual">Frank Sinatra</artist> <title numberoftracks="4">In The Wee Small Hours</title> <tracks> <track>In The Wee Small Hours</track> <track>Mood Indigo</track> <track>Glad To Be Unhappy</track> <track>I Get Along Without You Very Well</track> </tracks> <price>$12.99</price> </compactdisc> <compactdisc> <artist type="band">The Offspring</artist> <title numberoftracks="5">Americana</title> <tracks> <track>Welcome</track> <track>Have You Ever</track> <track>Staring At The Sun</track> <track>Pretty Fly (For A White Guy)</track> </tracks> <price>$12.99</price> </compactdisc> </compactdiscs>For example, track nodes, how shoud I do it?Tried like this but I get an error Variable must be of type "Object"$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks/track") For $oNode In $oNodes.childnodes ConsoleWrite($oNode.text & @CRLF) NextHow should I been doing it?EDIT: This mixes everything$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks/track") Do $oNode = $oNodes.nextNode() $t = $oNode.text ConsoleWrite($t & @CRLF) Until @error Or $t = '' is there a way to do this like this:1st return a array of objects with 2 rows ubound($tracks)=22nd return the matches of loop{$tracks.item(x).nextNode()}EDIT2: I think this is a small step to crawl a xml$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks") For $oNode in $oNodes $childs = $oNode.childNodes For $child in $childs ConsoleWrite($child.tagName&" = "&$child.text@LF) Next NextMy doubt now is, how can I recursive for child nodes in every single node? I'm in nodeception right now Edited April 29, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
mLipok Posted April 29, 2015 Share Posted April 29, 2015 (edited) some improvements;~ https://msdn.microsoft.com/en-us/library/aa468547.aspx #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir & "\example.xml") ConsoleWrite("$oXml.ReadyState = " & $oXml.ReadyState & @LF) Local $oNodes = $oXML.selectNodes("//tracks") Local $oChilds For $oNode In $oNodes $oChilds = $oNode.childNodes For $oChild In $oChilds ConsoleWrite($oChild.tagName & " = " & $oChild.text & @LF) ConsoleWrite($oChild.tagName & " = " & $oChild.text & @LF) ConsoleWrite($oChild.parentNode.nodeName & ':' & $oChild.nodeValue & @CRLF) Next Next ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Edited April 29, 2015 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Kyan Posted April 29, 2015 Author Share Posted April 29, 2015 (edited) thanks mLipok for helping out is only returning the readystate :|expandcollapse popup;~ https://msdn.microsoft.com/en-us/library/aa468547.aspx #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir & "\example.xml") ConsoleWrite("$oXml.ReadyState = [" & $oXml.ReadyState & "] " & _ReadyStates($oXml.ReadyState) & @LF) Local $oNodes = $oXML.selectNodes("//tracks") Local $oChilds For $oNode In $oNodes $oChilds = $oNode.childNodes For $oChild In $oChilds ConsoleWrite($oChild.tagName & " = " & $oChild.text & @LF) ConsoleWrite($oChild.parentNode.nodeName & ':' & $oChild.nodeValue & @CRLF) Next Next ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Func _ReadyStates($iRState) Switch $iRState Case 0 Return "The request is not initialized" Case 1 Return "The request has been set up" Case 2 Return "The request has been sent" Case 3 Return "The request is in process" Case 4 Return "The request is complete" EndSwitch EndFuncEDIT: Something fishy is going onConsoleWrite("outside"&@LF) For $oNode In $oNodes ConsoleWrite("inside"&@LF) ConsoleWrite(IsObj($oNode)&@LF) $oChilds = $oNode.childNodesoutput$oXml.ReadyState = [4] The request is complete outsideEDIT2: I'm not figuring out what is going on :\ConsoleWrite($oNodes.nodeName&@LF) ->Gives err 0x80020006ConsoleWrite($oNodes.firstChild.nodeName&@LF) ->Gives err 0x80020006ConsoleWrite($oNodes.item(0).nodeName&@LF) ->BISEDIT3: I give up, if there was a ShowDOMList function it would totally help out (like _ArrayDisplay but for DOM objects) Edited April 29, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted May 1, 2015 Author Share Posted May 1, 2015 Bump peri bumpAny tip how to recursively check for sub nodes in each read node? and how would I return those values in a orderly fashion? Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
mLipok Posted May 2, 2015 Share Posted May 2, 2015 Try this:#include-once #include <_XMLDomWrapper.au3> #include <Array.au3> _XMLFileOpen(@ScriptDir & "\example.xml") MsgBox(0, '@error', @extended) $aNodes = _XMLGetChildNodes("/compactdiscs") For $iNode = 1 To $aNodes[0] $POLY_COORDS = _XMLGetChildren("compactdiscs/" & $aNodes[$iNode]) ConsoleWrite("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]" & @CRLF) $ID = _XMLGetAttrib("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]", "id") MsgBox(0, $ID, StringReplace($POLY_COORDS[1][1], @TAB, "")) NextBut remove this line from example.xml<!DOCTYPE compactdiscs SYSTEM "cds.dtd"> Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Kyan Posted May 5, 2015 Author Share Posted May 5, 2015 sorry for asking, but where do I find the _XMLDomWrapper.au3? I searched on examples but no topics were found .\ Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
mLipok Posted May 5, 2015 Share Posted May 5, 2015 Kyan 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Kyan Posted May 5, 2015 Author Share Posted May 5, 2015 (edited) I removed the line but it gives me this error from the msgbox -2146697210I used your last code: #include-once #include <_XMLDomWrapper.au3> #include <Array.au3> _XMLFileOpen(@ScriptDir & "\example.xml") MsgBox(0, '@error', @extended) $aNodes = _XMLGetChildNodes("/compactdiscs") For $iNode = 1 To $aNodes[0] $POLY_COORDS = _XMLGetChildren("compactdiscs/" & $aNodes[$iNode]) ConsoleWrite("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]" & @CRLF) $ID = _XMLGetAttrib("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]", "id") MsgBox(0, $ID, StringReplace($POLY_COORDS[1][1], @TAB, "")) Nextand example.xml had been edited to<?xml version="1.0"?> <compactdiscs> <compactdisc> <artist type="individual">Frank Sinatra</artist> <title numberoftracks="4">In The Wee Small Hours</title> <tracks> <track>In The Wee Small Hours</track> <track>Mood Indigo</track> <track>Glad To Be Unhappy</track> <track>I Get Along Without You Very Well</track> </tracks> <price>$12.99</price> </compactdisc> <compactdisc> <artist type="band">The Offspring</artist> <title numberoftracks="5">Americana</title> <tracks> <track>Welcome</track> <track>Have You Ever</track> <track>Staring At The Sun</track> <track>Pretty Fly (For A White Guy)</track> </tracks> <price>$12.99</price> </compactdisc> </compactdiscs> Edited May 17, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
mLipok Posted May 17, 2015 Share Posted May 17, 2015 Hi, this piece of non-sense doesn't even gives an xml file as example https://msdn.microsoft.com/en-us/library/ms754523(v=vs.85).aspxHow do I call and retrieve all the matches node?<?xml version="1.0"?> <!DOCTYPE compactdiscs SYSTEM "cds.dtd"> <compactdiscs> <compactdisc> <artist type="individual">Frank Sinatra</artist> <title numberoftracks="4">In The Wee Small Hours</title> <tracks> <track>In The Wee Small Hours</track> <track>Mood Indigo</track> <track>Glad To Be Unhappy</track> <track>I Get Along Without You Very Well</track> </tracks> <price>$12.99</price> </compactdisc> <compactdisc> <artist type="band">The Offspring</artist> <title numberoftracks="5">Americana</title> <tracks> <track>Welcome</track> <track>Have You Ever</track> <track>Staring At The Sun</track> <track>Pretty Fly (For A White Guy)</track> </tracks> <price>$12.99</price> </compactdisc> </compactdiscs>For example, track nodes, how shoud I do it?Tried like this but I get an error Variable must be of type "Object"$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks/track") For $oNode In $oNodes.childnodes ConsoleWrite($oNode.text & @CRLF) NextHow should I been doing it?EDIT: This mixes everything$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks/track") Do $oNode = $oNodes.nextNode() $t = $oNode.text ConsoleWrite($t & @CRLF) Until @error Or $t = '' is there a way to do this like this:1st return a array of objects with 2 rows ubound($tracks)=22nd return the matches of loop{$tracks.item(x).nextNode()}EDIT2: I think this is a small step to crawl a xml$oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load(@DesktopDir&"\example.xml") $oNodes = $oXML.selectNodes("//tracks") For $oNode in $oNodes $childs = $oNode.childNodes For $child in $childs ConsoleWrite($child.tagName&" = "&$child.text@LF) Next NextMy doubt now is, how can I recursive for child nodes in every single node? I'm in nodeception right nowYou can use your XML example with this code:expandcollapse popup;~ https://msdn.microsoft.com/en-us/library/aa468547.aspx #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $objDoc = ObjCreate("Msxml2.DOMDocument.4.0") $objDoc.validateOnParse = False $objDoc.load(@ScriptDir & "\example.xml") _XML_ErrorParser($objDoc) $objDoc.setProperty("SelectionLanguage", "XPath") _XML_ErrorParser($objDoc) $objDoc.setProperty("SelectionNamespaces", '') _XML_ErrorParser($objDoc) ConsoleWrite("$objDoc.ReadyState = " & $objDoc.ReadyState & @LF) Local $oCurrNode = $objDoc.documentElement.childNodes.item(1); ConsoleWrite($oCurrNode.xml & @CRLF); ;~ Local $oNodes = $objDoc.SelectNodes("/compactdiscs/compactdisc/tracks") Local $oNodes = $objDoc.SelectNodes("/compactdiscs/compactdisc/tracks") ;~ _XML_ErrorParser($objDoc) ;~ MsgBox(0, '', $oNodes.xml) If IsObj($oNodes) Then ;~ https://msdn.microsoft.com/en-us/library/ms757852(v=vs.85).aspx MsgBox(0, '1', $oNodes.expr) MsgBox(0, '2', $oNodes.length) MsgBox(0, '3', $oNodes.context) Local $iStep = 1 For $oNode In $oNodes ConsoleWrite('$iStep = ' & $iStep & @CRLF) $iStep += 1 ConsoleWrite($oNode.nodeName & ':' & $oNode.nodeValue & @CRLF) ConsoleWrite($oNode.nodeType & ':' & $oNode.nodeValue & @CRLF) Next EndIf ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _XML_ErrorParser ; Description ...: Parse Error to Console ; Syntax ........: _XML_ErrorParser(Byref $objDoc) ; Parameters ....: $objDoc - [in/out] an object. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://msdn.microsoft.com/en-us/library/ms767720(v=vs.85).aspx , https://msdn.microsoft.com/en-us/library/ms757019(v=vs.85).aspx ; Example .......: No ; =============================================================================================================================== Func _XML_ErrorParser(ByRef $objDoc) If $objDoc.parseError.errorCode <> 0 Then ConsoleWrite('IXMLDOMParseError errorCode = ' & $objDoc.parseError.errorCode & @CRLF) ; Contains the error code of the last parse error. ConsoleWrite('IXMLDOMParseError filepos = ' & $objDoc.parseError.filepos & @CRLF) ; Contains the absolute file position where the error occurred. ConsoleWrite('IXMLDOMParseError line = ' & $objDoc.parseError.line & @CRLF) ; Specifies the line number that contains the error. ConsoleWrite('IXMLDOMParseError linepos = ' & $objDoc.parseError.linepos & @CRLF) ; Contains the character position within the line where the error occurred. ConsoleWrite('IXMLDOMParseError reason = ' & $objDoc.parseError.reason & @CRLF) ; Describes the reason for the error. ConsoleWrite('IXMLDOMParseError srcText = ' & $objDoc.parseError.srcText & @CRLF) ; Returns the full text of the line containing the error. ConsoleWrite('IXMLDOMParseError url = ' & $objDoc.parseError.url & @CRLF) ; Contains the URL of the XML document containing the last error. ConsoleWrite('.............................................................................' & @CRLF) EndIf EndFunc ;==>_XML_ErrorParser Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
pseakins Posted August 3, 2015 Share Posted August 3, 2015 Try this:#include-once #include <_XMLDomWrapper.au3> #include <Array.au3> _XMLFileOpen(@ScriptDir & "\example.xml") MsgBox(0, '@error', @extended) $aNodes = _XMLGetChildNodes("/compactdiscs") For $iNode = 1 To $aNodes[0] $POLY_COORDS = _XMLGetChildren("compactdiscs/" & $aNodes[$iNode]) ConsoleWrite("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]" & @CRLF) $ID = _XMLGetAttrib("/compactdiscs/" & $aNodes[$iNode] & "[" & $iNode & "]", "id") MsgBox(0, $ID, StringReplace($POLY_COORDS[1][1], @TAB, "")) NextI don't understand how this could work. In _XMLDomWrapper.au3 (Global Const $_XMLUDFVER = "1.0.3.98") the functions _XMLGetChildNodes and _XMLGetChildren require two args eg., '(Func _XMLGetChildren(ByRef $objDoc, $strXPath)' but this example only supplies one argument. Perhaps you are working with an older version of _XMLDomWrapper?I've been struggling for days trying to get the various usage examples on the forum for _XMLDomWrapper to work but they all fail due to this same incompatibility. Perhaps i am missing something obvious but I'm afraid I can't see it. Any help would be appreciated. Phil Seakins Link to comment Share on other sites More sharing options...
mLipok Posted August 3, 2015 Share Posted August 3, 2015 I don't understand how this could work. In _XMLDomWrapper.au3 (Global Const $_XMLUDFVER = "1.0.3.98") the functions _XMLGetChildNodes and _XMLGetChildren require two args eg., '(Func _XMLGetChildren(ByRef $objDoc, $strXPath)' but this example only supplies one argument. Perhaps you are working with an older version of _XMLDomWrapper?Yes. When I post a link in post #7 then this was "1.0.3.87"Actually I'm on vacation , regardless of that I have some other work to do.I'm not a "master of XML" but I can back to XML in two weeks, when I was a plan to back to work with my XMLDomWrapper update. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
pseakins Posted August 4, 2015 Share Posted August 4, 2015 Yes. When I post a link in post #7 then this was "1.0.3.87"Actually I'm on vacation , regardless of that I have some other work to do.I'm not a "master of XML" but I can back to XML in two weeks, when I was a plan to back to work with my XMLDomWrapper update. Yes, thank you. There is no hurry for me, I found out how to use the new UDF. It has undocumented, code breaking changes. To use it you need to add the global variable $objDoc as the first argument in the call to the changed functions. Phil Seakins 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