jpam Posted May 25, 2006 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
Lazycat Posted May 25, 2006 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])
jpam Posted May 25, 2006 Author 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
jpam Posted May 26, 2006 Author 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??
Lazycat Posted May 26, 2006 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])
jpam Posted May 26, 2006 Author 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!
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