Jump to content

xml


Recommended Posts

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 by jpam
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...