Create a Track object which has "name" and "artist"" properties. Write 1
line simple setters and getters and a constructor that takes an XML
subtree and extracts the Track detail (This way you can add more to the
track without having to touch anyone else.)
Create a "root" object that has a list of Track objects and a method
getTrack(n) that returns the nth track.
The constructor for Root takes the XML as an argument and creates an
array of Track Objects by passing in the sub-tree for each track when it
finds one in the XML tree.
artistName=root.getTrack(2).getArtistName();
Very simple code. Easy to debug and maintain.
Ron
Johan Nyberg wrote:
Hi, what I need is basically a class that puts all the data in an
associative array, or numeric, depending on if I'm storing values for
individual nodes, or a "mothernode".
Now I find there is a lot of looping going on every time I have to
parse a XML, and XPath seems more like the thing you want to use if
you're looking for specific data inside the XML - I just want to put
all the data in an Array or Object...
For example:
<root>
<track>
<name></name>
<artist></artist>
</track>
<track>
<name></name>
<artist></artist>
</track>
</root>
I would like it like this: root[track[n]["artist"]]
Regards,
/Johan
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com