in reply to perl XML::LibXML help reading an xml file that uses namespaces
Hi HeadScratcher,
tell the difference between the 2 'title' fields
//dft:title means to find the corresponding <title> nodes anywhere in the tree. To select the <title> that is a child of <feed>, use for example /dft:feed/dft:title, or to select <title> nodes that are children of <entry> nodes anywhere in the tree, you could use //dft:entry/dft:title. There are other ways to tell nodes apart, such as using attributes, siblings, etc. - choosing the correct XPath conditions for selecting the nodes is up to you, depending on the structure of the document and your own criteria.
how do I get the value of point?
xmlns="http://www.w3.org/2005/Atom" will be the namespace of nodes that don't have any prefix. So <point> is in that namespace, and in your XPath you've given that namespace the alias dft. The proper XPath expression is then //georss:where/dft:point
Note these aren't really Perl questions, really more like XPath questions, you I'd recommend you look into XPath a bit more.
Hope this helps,
-- Hauke D
Update: s/direct descendant/child/g
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl XML::LibXML help reading an xml file that uses namespaces
by HeadScratcher (Novice) on Aug 07, 2016 at 14:50 UTC |