freshgrill
asked on
Perl XML get children
I have the following code, but I want to follow all the children (of the children), etc.. to printer a "flat" complete list of elements.
$struct = $parser -> parse_file("$pid.dofiles.xml");
$rootel = $struct -> getDocumentElement();
$elname = $rootel -> getName();
print "Root element is a $elname and it contains ...\n";
@kids = $rootel -> childNodes();
foreach $child(@kids) {
$elname = $child -> getName();
@atts = $child -> getAttributes();
print "$elname (";
foreach $at (@atts) {
$na = $at -> getName();
$va = $at -> getValue();
print " ${na}[$va] ";
}
print ")\n";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK.
Now, it would greatly help if you provided a sample XML that you are parsing and the output you would like to see from it.
Now, it would greatly help if you provided a sample XML that you are parsing and the output you would like to see from it.
ASKER
use XML::XSLT qw(serve);
use XML::DOM;