banzai has asked for the wisdom of the Perl Monks concerning the following question:
what i want to do is get the textcontent of the childnotes of the "Entry" nodes and put them in a hash (e.g. $info{"lastname_no of entry, $info{"firstname_no of entry, etc) but i cannot for the life of me do it. what i have so far:<table> <Entry No="1"> <lastname_>Dasd</lastname_> <firstname_>Dasd</firstname_> <street_>Dasd</street_> <houseno_>12</houseno_> <zip_>1231</zip_> <city_>Dasd</city_> <sex_>maennlich</sex_> <marital_>geschieden</marital_> <character_>Brille Sommersprossen</character_> <description_>asdas </description_> </Entry> <Entry No="2"> <lastname_>Dasd</lastname_> <firstname_>Dasd</firstname_> <street_>Dasd</street_> <houseno_>12</houseno_> <zip_>1231</zip_> <city_>Dasds</city_> <sex_>maennlich</sex_> <marital_>geschieden</marital_> <character_>Brille Sommersprossen</character_> <description_>asdas </description_> </Entry> </table>
i would put the content of $tmpinfo into the hash later, but it tells me $tmpinfo is uninitialized? im so completely burnt out on this problem, please help.my $file = 'xml.xml'; my $parser = XML::LibXML->new(); my $tree = $parser->parse_file($file); my @tmpinfo; foreach my $sample ($tree->findnodes('/table/Entry')) { $i=0; foreach my $content ($sample->findnodes('*')) { $tmpinfo[$i]=$content->textContent; $i++; print $tmpinfo[$i]; } $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading XML LibXML (ddumper)
by Anonymous Monk on Oct 02, 2013 at 09:31 UTC | |
|
Re: Reading XML LibXML
by GotToBTru (Prior) on Oct 02, 2013 at 13:10 UTC | |
|
Re: Reading XML LibXML
by Jenda (Abbot) on Oct 02, 2013 at 15:44 UTC | |
|
Re: Reading XML LibXML
by Bloodnok (Vicar) on Oct 02, 2013 at 10:15 UTC | |
by Anonymous Monk on Oct 02, 2013 at 10:56 UTC | |
by hdb (Monsignor) on Oct 02, 2013 at 11:01 UTC | |
by McA (Priest) on Oct 02, 2013 at 11:07 UTC | |
by hdb (Monsignor) on Oct 02, 2013 at 11:11 UTC | |
| |
by Anonymous Monk on Oct 02, 2013 at 11:08 UTC | |
|
Re: Reading XML LibXML
by Anonymous Monk on Oct 02, 2013 at 13:14 UTC | |
by Jenda (Abbot) on Oct 02, 2013 at 15:40 UTC |