B
-Brad-
Hi all, Im using the XML:
OM module to process an xml document but having a
few problems.
Im trying to loop though all the node attributes and retreive their values.
But having a few promlems.
The Perl code I have so far is
foreach my $child ($root->getChildNodes()) {
if ($child->getNodeType == TEXT_NODE){
#print "Text: ", $child->getData();
print "--------\n";
} elsif ($child->getNodeType == ELEMENT_NODE) {
print $child->getNodeName(), " = ",
$child->getFirstChild()->getData(), "\n";
$attribs = $child->getAttributes();
while ( my ($key, $value) = each(%$attribs) ) {
print "$key => $value\n";
# HERE I WOULD LIKE TO PRINT THE NAME AND VALUE OF
THE ATTRIBUTES
}
#$att = $attribs->getNamedItem("LetterHasDate");
#print " Attribute = " , $att->getValue() , "\n";
#print " ALSO = " ,
$child->getAttributes()->getNamedItem("att")->getValue() , "\n";
}
}
----------------When Run it gives me this. ---------------------
RequestID => XML:
OM::Attr=ARRAY(0x84d5908)
LetterHasSignatory => XML:
OM::Attr=ARRAY(0x84d699c)
LetterHasParameters => XML:
OM::Attr=ARRAY(0x84d6c3c)
ActionCode => XML:
OM::Attr=ARRAY(0x84d5740)
------------------------------------------------------------------
So as you can see it prints the $key valus out correctly, but the $value
seems to be an array.
How would I go about printing that out?
Thank you!
few problems.
Im trying to loop though all the node attributes and retreive their values.
But having a few promlems.
The Perl code I have so far is
foreach my $child ($root->getChildNodes()) {
if ($child->getNodeType == TEXT_NODE){
#print "Text: ", $child->getData();
print "--------\n";
} elsif ($child->getNodeType == ELEMENT_NODE) {
print $child->getNodeName(), " = ",
$child->getFirstChild()->getData(), "\n";
$attribs = $child->getAttributes();
while ( my ($key, $value) = each(%$attribs) ) {
print "$key => $value\n";
# HERE I WOULD LIKE TO PRINT THE NAME AND VALUE OF
THE ATTRIBUTES
}
#$att = $attribs->getNamedItem("LetterHasDate");
#print " Attribute = " , $att->getValue() , "\n";
#print " ALSO = " ,
$child->getAttributes()->getNamedItem("att")->getValue() , "\n";
}
}
----------------When Run it gives me this. ---------------------
RequestID => XML:
LetterHasSignatory => XML:
LetterHasParameters => XML:
ActionCode => XML:
------------------------------------------------------------------
So as you can see it prints the $key valus out correctly, but the $value
seems to be an array.
How would I go about printing that out?
Thank you!