I'm a humble peasant seeking the wisdom of the holy ones please enlighten me

I'm attempting to extract elements from an XML file

in the code bellow how do I adapt it so I can tell the difference between the 2 'title' fields and how do I get the value of point?

I'm hoping if I can work this out I can use the same principle to extract other items like author

#!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:title'); print "title $title\n"; my $point = $xpc->findnodes('//georss:where/point'); print "point $point\n";

OUTPUT from above code

title EarthquakesM 3.2, Mona Passage

point

georss.xml

<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.geo +rss.org/georss" xmlns:gml="http://www.opengis.net/gml"> <title>Earthquakes</title> <subtitle>International earthquake observation labs</subtitle> <link href="http://example.org/" /> <updated>2005-12-13T18:30:02Z</updated> <author> <name>Dr. Thaddeus Remor</name> <email>tremor@quakelab.edu</email> </author> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry> <title>M 3.2, Mona Passage</title> <link href="http://example.org/2005/09/09/atom01" /> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2005-08-17T07:02:32Z</updated> <summary>We just had a big one.</summary> <georss:where> <point>45.256 -71.92</point> </georss:where> </entry> </feed>

In reply to perl XML::LibXML help reading an xml file that uses namespaces by HeadScratcher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.