I have the following XML –
<title type="text/html">First part of string</title>
<content type="text/html"><p>And Second part of string</p> </content>
<link rel="alternate" type="text/html" href="http://www.FooBar.com"/>
And have used the following script in XPath –
use XML::XPath;
use XML::XPath::XMLParser;
my $file = 'MY.xml';
my $xp = XML::XPath->new(filename=>$file);
my $body = $xp->findvalue('entry/activity:object/content');
print "$body\n";
my $title = $xp->findvalue('entry/activity:object/title');
print "$title\n";
Which returns –
First part of string And Second part of string
I also need it to output the –
http://www.FooBar.com
I tried adding –
my $URL = $xp->findvalue('entry/activity:object/link');
print "$URL\n";
But this did not output anything.
How can I edit my script to include the URL string?
The href value is an attribute of the link element, so use: