Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Help with Hashs/Arrays and XML::Simple
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jasper2000, post: 4871640"] Hi, I'm trying to write a little script that does a query and which returns XML data. That part is fine, and I thought I'd be okay with XML::Simple, since I used it a day or two ago, with XML returned from a different service, and I seemed to understand it fine, and it was working. However, the XML in this new script is a bit more complex, and I don't seem to be able to get it working. Here is the top snippet and first complete "Item" from the XML file: <SearchSuggestion version="2.0"> <Query xml:space="preserve">Clothes</Query> <Section> <Item> <Text xml:space="preserve">Clothing</Text> <Description xml:space="preserve">A feature of all modern human societies....</Description> <Url xml:space="preserve">[URL]http://someurl[/URL]....</Url> <Image source="[URL]http://someimageurl[/URL]" width="50" height="33"/> </Item> <Item> <Text xml:space="preserve">Clothes dryer</Text> <Description xml:space="preserve"> .... .... My snippet of Perl script looks like this: my $xml = new XML::Simple; # create object my $data = $xml->XMLin("data.xml"); foreach my $record (@{$data->{Section}->{Item}}) { print $record->{Text}, "<br />"; } My output, however, looks like this: HASH(0x1e35128)<br />HASH(0x1e35374)<br />HASH(0x1e35584)<br / HASH(0x1e35788) <br />HASH(0x1e4cfe0)<br />HASH(0x1e4d1e4)<br />HASH(0x1e4d3e8)<br /> HASH(0x1e4d5ec)<br />HASH(0x1e4d748)<br />HASH(0x1e4d8ec)<br /> I've tried various arrangements with the loop, but always seem to end up with either nothing or something similar to the above. Any help which can be provided would be most appreciated! Thanks! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Help with Hashs/Arrays and XML::Simple
Top