jpam Posted May 25, 2006 Share Posted May 25, 2006 (edited) please! Need help with parsing xml file what i have so far $xmlDoc = ObjCreate("Msxml2.DOMdocument.3.0") $xmlDoc.load("C:\books.xml") ;extract id $nodeBook = $xmlDoc.selectSingleNode("//book") $nodeId = $nodeBook.attributes.getNamedItem("id") MsgBox(64,"",$nodeId.value) ;extract authors $NodeList = $xmlDoc.getElementsByTagName("author") for $i=0 To $NodeList.length $value = $NodeList.item($i).text MsgBox(64,"",$value) Next Extracting the authors is doing well ,exept on the end of the xml file i got an error what is want is all the id' s like the authors can somebody help me with this? thanks in advance jpam,books.xml Edited May 25, 2006 by jpam Link to comment Share on other sites More sharing options...
Lazycat Posted May 25, 2006 Share Posted May 25, 2006 Isn't should loop be: for $i=0 To $NodeList.length - 1 ... ? Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
jpam Posted May 25, 2006 Author Share Posted May 25, 2006 Isn't should loop be: for $i=0 To $NodeList.length - 1 ... ? i see no difference in my script example with or without the -1 Link to comment Share on other sites More sharing options...
jpam Posted May 26, 2006 Author Share Posted May 26, 2006 yep ! your right lazycat! the missing -1 that causes the error on the end of the xml file only problem for me is extracting the id's now anybody?? Link to comment Share on other sites More sharing options...
Lazycat Posted May 26, 2006 Share Posted May 26, 2006 yep ! your right lazycat! the missing -1 that causes the error on the end of the xml file only problem for me is extracting the id's now anybody??Hm, you already have code for select "author" nodes. What the difference for select id's? $NodeList = $xmlDoc.selectNodes("book") for $i=0 To $NodeList.length - 1 $value = $NodeList.item($i).getAttribute("id") MsgBox(64,"",$value) Next Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
jpam Posted May 26, 2006 Author Share Posted May 26, 2006 Hm, you already have code for select "author" nodes. What the difference for select id's? $NodeList = $xmlDoc.selectNodes("book") for $i=0 To $NodeList.length - 1 $value = $NodeList.item($i).getAttribute("id") MsgBox(64,"",$value) Next Thanks a million lazycat ! you put me on the right track only thing that was missing is the 2 backslashes $NodeList = $xmlDoc.selectNodes("//book") now its working fine thanks again! 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