Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created September 26, 2012 02:51
Show Gist options
  • Save s4553711/3785727 to your computer and use it in GitHub Desktop.
Save s4553711/3785727 to your computer and use it in GitHub Desktop.
XML::Path Example for parsing uniprot data
#!/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