I'm using the following code:
use XML::TreeBuilder; foreach my $drug ($tree->find_by_tag_name('drug')){ my @targets = $drug->look_down ('_tag', 'targets')->look_down ('_tag', + 'target')->attr_get_i('partner'); foreach my $id (@targets){print "\t$id";} my @actions = $drug->look_down ('_tag', 'targets')->look_down ('_tag', + 'known-action')->as_text; foreach my $act (@actions){print "\t$act";} }
to read through the following XML:
<drug type="small molecule"> <name>Goserelin</name> <targets> <target partner="1"> <known-action>yes</known-action> <target partner="2"> <known-action>yes</known-action> <target partner="3"> <known-action>yes</known-action> </target>
but it will only prints the first result. How can I get it to capture all of the attributes and actions and print them out for each drug?
In reply to XML::TreeBuilder capture multiple attributes to array by yesitsjess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |