Hello all,
I am using Columbia's xml parser code found here
https://www.theswamp.org/index.php?topic=525.30It seems to be perfect for what I'm trying to accomplish but I have two small problems. Below is some example code of what my XML format looks like, except the actual will be much longer and have more layers.
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<!-- Note -->
<price>30.00</price>
</book>
<book>
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<!-- Note -->
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
Problem 1: Since the two child nodes "book" have the same name, I can't find a way to differentiate the two when using Columbia's get-child or get-child-value. The code always gives back the first child node because it searches by name. I was thinking about using get-child-list and using the positions to assign VLA objects to child nodes of the same name, but the number of "book" nodes will change with each XML file and I don't know if their positions will always be constant, I don't want that to make things messy. I was also thinking about replacing "book" with "book1", "book2", ... while there is a child node with the name "book". I think put-value function does that. Or, if there's something very simple I'm missing I would greatly appreciate someone filling me in.
Problem 2: As far as I know, Columbia's code can not handle notes in XML. When I use get-child-value on the first node "book" I can extract data from title, author, and year, but not price. When I use get-child-value on the second node "book" (and change it to a unique title) I can extract data from title and author, but not year and price. It returns error unknown name: TAGNAME. When I remove the notes, I can get all values no problem. Should I somehow remove all notes from the files beforehand? Can I write a couple lines of code into Columbia's file to skip over the notes? Or again, is there something simple I am missing here?
Please inform me on what the simplest solutions are to my two problems. Also, I am very new to computer programming in general so I would appreciate it if everyone spoke to me as if I were a small child.
Thanks