Usually when parsing XML i have to create all those lists with nodes, childs and what not.
Maybe there’s a more simple way?…
For example I have a document that contains a few elements which id starts with “patch”.
<rect id="patchW" x="48" display="none" fill="#993333" width="48" height="75"/>
And what I need is to make a list that would contain id ( of the elements that start with “patch” ), x and y ( if not present, then 0 ).
What do you think would be the best way of doing it?
Thanks!
Your best bet is SAX, which will fire events such as “start of element,” “end of element,” etc. Just listen to the start element events, and add the information you care about into a list every time you get an element whose ID starts with patch. Also, SAX is extremely fast – a lot of other XML parsing libraries, such as DOM, are built on top of SAX.