OOPS sorry again! That XML still incomplete, this is correct now:
<drug type="small molecule"> <name>Goserelin</name> <targets> <target partner="1"> <known-action>yes</known-action> </target> <target partner="2"> <known-action>yes</known-action> </target> <target partner="3"> <known-action>yes</known-action> </target> </target> </drug>
Here's the complete Perl script, which just got deleted when I updated:
use XML::TreeBuilder; my $file = $ARGV[0]; my $tree = XML::TreeBuilder->new(); $tree->parse_file($file); 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";} }
And also because I updated I think all my apologising is gone, so just to summarise: I'm sorry for how that came across, I was just trying to let people know that I really do appreciate the help a lot
In reply to Re^4: XML::TreeBuilder capture multiple attributes to array
by yesitsjess
in thread XML::TreeBuilder capture multiple attributes to array
by yesitsjess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |