AboutJustin Wheeler Expertise Any question relating to Perl including its internals, data structures, speed, memory usage, syntax, version changes, extra CPAN modules, code standards, code cleanup, or just silly problems.
Experience I have been writing Perl code professionally for almost 10 years. I have modules on CPAN, have Perl code that's included in the latest versions of Redhat, Debian, etc. I have done professional Perl work for many household names including Ticketmaster, Interflora, and allbookstores.com.
Education/Credentials Only work experience and a love of all things Perl.
Question I'm trying to user xml:simple to break down an xml doc that I'm receiving from another website. I've been able to use xml:simple for other projects I have but this one I'm guessing is going to require a foreach statement. Im not 100% sure how to go about this.. An example of the xml file is below:
<outer>
<xml>
<undeveloped_lands>
<land>
<id>1</id>
<image_url></image_url>
<details></details>
<num_owned></num_owned>
<cost></cost>
<name></name>
<income></income>
</land>
<land>
<id>2</id>
<image_url></image_url>
<details></details>
<num_owned></num_owned>
<cost></cost>
<name></name>
<income></income>
</land>
<land>
<id>3</id>
<image_url></image_url>
<details></details>
<num_owned></num_owned>
<cost></cost>
<name></name>
<income></income>
</land>
</undeveloped_lands>
</xml>
</outer>
I need to get each set of info and going to place them into different tables. How would I go about this?
Answer Hi Matthew,
Yes, you'll likely need a foreach or something like that to traverse the data.
Your best bet is to XMLin() the file with XML::Simple, and then use Data::Dumper to Dumper() the data structure you get back. Then, you'll clearly be able to figure out how to navigate the data.