s4553711
9/26/2012 - 2:51 AM

XML::Path Example for parsing uniprot data

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";
}