|
I found a lightweight XML reader here which I would like to use over TinyXMLReader as it has the ability to parse attributes. The problem is that I have literally no idea how to use this parser. TinyXMLReader provided a working example but this doesn't provide anything. So does anyone here have any experience with this particular script? If you do, please provide a simple example of how to use and I'm sure I'll quickly come to grasps with it. Thanks.
(comments are locked)
|
|
There are two basic types of XML parser: those that traverse the logical tree as they parse and those that build a tree which you then traverse at your leisure. This is of the latter kind. Generally this is easier and more powerful too. It's a DOM tree (sort of). But how would I then traverse the tree? :P
Jul 30 '11 at 11:51 AM
AaronG
See the example at that link - it traverses the tree in order to write it back out as XML - quite a good test and example, I think. Once you've used the DOM-style, you'll never want to go back.
Jul 30 '11 at 12:11 PM
Waz
It will output the entire XML to the console but how is that of use to me? Please provide a more contextual example. :( For example, I have MyNameIsBob in an XML file between a tags called 'Name'. I load it up via the parser and want to store the value between those tags in a string variable. How would I do this?
Jul 30 '11 at 01:36 PM
AaronG
Perhaps you should stick with the reader you understand.
Jul 30 '11 at 08:40 PM
Waz
Traversing a tree is a basic programming concept. You walk from node to node, look at each node to decide wether to go into it's substructure. In your case, you look for the Name node.
Jul 30 '11 at 08:43 PM
Waz
(comments are locked)
|

What's wrong with using the usage example Cameron presents on the forum post you link to? It just loads an XML file from the Resources folder, parses it, and then dumps the xml out from the data returned by the parsing.
With TinyXMLReader I can execute code base on the currently open tag such as...
if (reader.tagName == "MyTag") { numMyTag++ }
But I don't understand how, using this parser, I can store information between tags into variables.