asked on
!C:\strawberry\perl\bin\perl.exe
use strict;
use warnings;
use XML::LibXML;
use XML::LibXML::XPathContext;
use Data::Dump qw(dump);
my $filename = 'georss.xml';
my $dom = XML::LibXML->load_xml(location => $filename);
my $xpc = XML::LibXML::XPathContext->new($dom);
$xpc->registerNs(dft => "http://www.w3.org/2005/Atom");
$xpc->registerNs(georss => "http://www.georss.org/georss");
foreach my $Entry ($xpc->findnodes("//dft:feed/dft:entry")) {
foreach my $Images ($xpc->findnodes("/dft:title[not(\@type='text')]", $Entry)) {
my $ImageVal = $Images->textContent;
#### This finds all the Images
print "ImageVal $ImageVal\n";
my $link = $Images->following-sibling::link[\@href];
print "link $link\n";
}
}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" >
<entry>
<title>fileName1.jpg</title>
<link href="PathTo/fileName1.jpg" />
</entry>
<entry>
<title>fileName2.jpg</title>
<link href="PathTo/fileName2.jpg" />
</entry>
<entry>
<title>fileName3.jpg</title>
<link href="PathTo/fileName3.jpg" />
</entry>
<entry>
<title type="text">fileName.pdf</title>
<link type="application/pdf" href="PathTo/fileName.pdf" />
</entry>
<georss:where>
<point xmlns="http://www.opengis.net/gml" srsName="urn:ogc:crs:EPSG:4326">
<pos>45.256 -71.92</pos>
</point>
</georss:where>
</feed>