vili has asked for the wisdom of the Perl Monks concerning the following question:

dear monks, xml... how tedious. i am in desperate need of some, triks to parse nested structures such as this one:
<tradein_value> <extra_clean/> <clean>3225</clean> <average>1975</average> <rough>1025</rough> </tradein_value> - <wholesale_value> <extra_clean>0</extra_clean> <clean>3150</clean> <average>1900</average> <rough>1050</rough> </wholesale_value> - <retail_value> <extra_clean>0</extra_clean> <clean>5075</clean> <average>3300</average> <rough>2250</rough> </retail_value>

using XML::Parser. or whatever might be better... without having to write thousands lines of code... typing is a struggle...
if someone may suggest a way, or refer me to some appropriate location, that describes such a way, or if
anyone had any ideas as to why the XML::Dumper::xml2pl might not be working for me, please tell me...
i'd be eternaly grateful...

humbly

updates:
yes there are start and end tags, that was just a snipet which i didnt indicate..
the complete xml can be seen at xml
i'd like to suck this into several mysql tables
an xml2mysql.pl if you will -- Thank you ~ vili

Replies are listed 'Best First'.
Re: Parsing nested XML
by Joost (Canon) on Jul 07, 2004 at 21:49 UTC
•Re: Parsing nested XML
by merlyn (Sage) on Jul 07, 2004 at 22:57 UTC
    That's not truly XML, unless there's an outer start-tag/end-tag around it that you're not showing. If there isn't, and it's just a bunch of elements without a container, you'll have to fake up a container enclosing the remaining file contents.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Parsing nested XML
by grantm (Parson) on Jul 08, 2004 at 01:31 UTC

    You haven't given us very much information. What does "parse nested structures such as this one" mean? What do you want to achieve by parsing the XML? Are you trying to extract one or two specific data items or are you trying to translate the whole XML document into a Perl data structure? If the latter, what do you want to do with it then?

    The Perl XML FAQ contains some advice on choosing an appropriate parser module. The best answer will depend on what you want to achieve.