I've beaten my head against the wall trying to get XML::Parser to chop up my file in the right way. XML::Parser seems to be a good tool for the job since I need to use the Stream mode and it is already installed.
When trying to parse this file
<?xml version="1.0" encoding="UTF-8"?>
<web property="perl.com" id="12345" date="2004-07-29">
<level>
<page name="dodo bird"/>
<page name="camel"/>
</level>
<content>
<file type="text/*" number="123" bytes="654322"/>
<file type="image/*" number="23" bytes="7654322"/>
</content>
<user>
<Product>
<Name>Product1</Name>
<Quantity>1</Quantity>
</Product>
<Product>
<Name>Product2</Name>
<Quantity>1</Quantity>
</Product>
</user>
</web>
I'm having issues coercing the structure into a record that I can easily output. For example, I'd like to have a record like $data{ $id }->{level}->{page}->{name} where name contains both "dodo bird" and "camel"
I've read the tutorial here and that method works well when there are not multiple elements with the same name. It doesn't work well with this exampel
You know when you're trying to think of a movie star's name...and you just can't seem to come up with it? Such is my pain. Any advice is appreciated.
Anon Monk
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.