Created
September 26, 2012 02:51
-
-
Save s4553711/3785727 to your computer and use it in GitHub Desktop.
XML::Path Example for parsing uniprot data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use XML::XPath; | |
use XML::XPath::XMLParser; | |
use WWW::Mechanize; | |
# To get the unirprot data through WWW::Mechanize | |
my $w = WWW::Mechanize->new(); | |
$w->get("http://www.uniprot.org/uniprot/P05067.xml"); | |
# Initial | |
my $a = XML::XPath->new(xml=>$w->content); | |
# Using XPath to find out the node | |
my $n = $a->find('/uniprot/entry/reference/citation/title'); | |
# Iterator through the node list | |
foreach my $node ($n->get_nodelist) { | |
print ">> ".$node->getName()." : ".$node->string_value."\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment