I have the xml below and I am trying to parse it
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
<offer id="60046">
<state>CO</state>
<zip>80236</zip>
<transit>1</transit>
<phone_public>1</phone_public>
<smoking></smoking>
</offer>
<offer id="6">
<state>MI</state>
<zip>48120</zip>
<transit>1</transit>
<phone_public>1</phone_public>
<smoking></smoking>
</offer>
<offer id="7">
<state>MI</state>
<zip>43240</zip>
<transit>1</transit>
<phone_public>1</phone_public>
<smoking></smoking>
</offer>
here is my perlcode
use XML::Simple;
my $content = get(xml.file);
my $response = XMLin($content);
What I need is a line of code that will let me do a
print $response->{'offer'}->{zip}
and it give me 3 zip codes for the 3 zip codes in an xml file. I would really like it to be in a while loop.
Please help me, I am working on a project for victims of katrina.
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.