Hi.I'm trying to make a small script that parses through an XML file. I don't have a lot of experience with XML but I managed to create a script (ASP) where I can access the contents of the XML file like this:
Set objXML = Server.CreateObject("Microsoft.XMLDOM")objXML.async = false objXML.load(source) Set objLst = objXML.getElementsByTagName("*")For i = 0 to (objLst.length-1)select case objLst.item(i).nodeName ' CODE HEREend selectSet objXML = nothing
Now. The content of the XML apparently does not contain blank nodes if the values are non-existing. Like this: (Madonna doesn't have a lastname (lname)).
<person> <fname>Allan</fname> <lname>Rogers</lname> <fname>Madonna</fname> <fname>Peter</fname> <lname>Smith</lname></person>
While looping through the content of the XML file I want to know when I have a complete set of information about ONE person, and the use that information to select against a database to compare info.But I can't tell when a new persons info. ends if the last node is not the same everytime.So I tried looking for fname, if I hit fname that meant that all info. had been gathered about ONE person. But then the last "unit" wouldn't get collected since there's no <fname> before </person>. For that I tried finding some sort of EOF property for XML but didn't suceeded. I did try using objLst.length to determine if I was at the end of the XML file, but apparently it doesn't take the very last node with it.If my code is placed in the top of the code around the first tag, it doesn't reach the last nodes and if the code is placed after collecting all nodes I can't look the next new "person" by fname.Perhaps I'm doing this all wrong, so I'd appreciate if someone have any ideas on how to proceed.