diamantis has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to parse a simple XML file with the XML::Parser module. I use the Stream style as it seems more appropriate for my needs. I would like to make a graph out of some entries in the xml file, but I have a hard time parsing correctly the text of some entries. It seems that the Text subroutine is called a couple of times in the beginning AND in the end of each entry. Is there any way to control this behavior? Perhaps I haven't understood something about parsing XML's but it seems to me more reasonable to call the Text sub once for each entry in a consistent way (beginning OR end) which would make my code much simpler and easy.
Any recommendations on what to do?
The main part of the input file looks like:
so I made a stack containing the innermost entry (adding in sub StartTag and removing when in EndTag) I was planning to add a list for pushing Text strings in it while in sub Text, but...I got stuck<entry> this is the text I would like to parse</entry> <entry>more text <secondentry>interesting text</secondentry> </entry>
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: confused with Stream style in XML::Parser
by Fletch (Bishop) on Oct 06, 2008 at 18:43 UTC | |
|
Re: confused with Stream style in XML::Parser
by Anonymous Monk on Oct 06, 2008 at 21:14 UTC |