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++; }
In reply to Reading XML LibXML by banzai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |