#!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");
my $title = $xpc->findnodes('//dft:feed/dft:title');
print "title $title\n"; # GOOD
#my $point = $xpc->findnodes('//dft:feed/georss:where/dft:Point/dft:pos'); ## this doesn't find anything
my $point = $xpc->findnodes('//dft:feed/georss:where');
$point =~ s/^\s*//; # clean white space unsure why but had loads
$point =~ s/\s*$//;
print "point $point\n"; # GOOD
foreach my $Etitle ($dom->findnodes('//dft:feed/dft:title)) {
print "Etitle $Etitle\n"; # prints <title type="text">fileName.pdf</title>
my $EtitleVal = $Etitle->findvalue('./title');
if($Etilte =~ m/jpg/){
print "Image $EtitleVal\n"; # prints Image
}
elsif($Etilte =~ m/pdf/){
print "PDF $EtitleVal\n"; # prints <title type="text">fileName.pdf</title>
}
}
<?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"sc:countryCodes=”US”>
<title type="text">Earthquakes</title>
<subtitle>International earthquake observation labs</subtitle>
<link href="http://example.org/" />
<updated>2005-12-13T18:30:02Z</updated>
<category term="Note" label ="Note" url="http://exampleurl.com/pathto/" />
<category term="Wanted" label ="Wanted" url="http://otherurl.com/pathto/FINDME" />
<author>
<name>Dr. Thaddeus Remor</name>
<email>tremor@quakelab.edu</email>
</author>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<georss:where>
<point xmlns="http://www.opengis.net/gml" srsName="urn:ogc:crs:EPSG:4326>
<pos>45.256 -71.92</pos>
</point>
</georss:where>
<entry>
<title type="text">fileName.pdf</title>
</entry>
<entry>
<title>fileName.jpg</title>
</entry>
</feed>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.