我有以下 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"/>
并在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";
哪个返回 -
First part of string And Second part of string
我还需要它来输出 -
http://www.FooBar.com
我尝试添加 -
my $URL = $xp->findvalue('entry/activity:object/link');
print "$URL\n";
但这并没有输出任何东西。
如何编辑我的脚本以包含 URL 字符串?