in reply to Re: xmlns and XML::LibXML ( local-name() )
in thread xmlns and XML::LibXML

you only need to match on local-name()

... which would make code non-namespace-aware and doesn't answer the question "how I am supposed to make XML::LibXML correctly use name spaces" (the answer recommended by XML::LibXML is XML::LibXML::XPathContext). The whole topic has been discussed before, actually in the thread you linked to: Xpath not working.

  • Comment on Re^2: xmlns and XML::LibXML ( local-name() )

Replies are listed 'Best First'.
Re^3: xmlns and XML::LibXML ( local-name() )
by Anonymous Monk on Jun 02, 2015 at 03:29 UTC

    ..which would make code non-namespace-aware and doesn't answer the question...The whole topic has been discussed before, actually in the thread you linked to..

    Hmm, I wonder why I linked that threat, its almost like I want folks to read it and make up their own minds

      I have read all the threads I can find. (Different from understanding them all perhaps) and I have not found the answer

      I have been using XML examples from the RFC4918, but the two namespace cases are different in other ways too. So I will construct an example

      Is it true that:

      <?xml version="1.0" encoding="utf-8" ?> <propfind xmlns="DAV:"> <propname/> </propfind>

      and

      <?xml version="1.0" encoding="utf-8" ?> <D:propfind xmlns:D="DAV:"> <D:propname/> </D:propfind>

      are the same (semantically)?

      If so then the same Perl code should parse them, if not I am more confused than I thought

      Worik

      Update: The same Perl code and Xpath
        Yes.
        #! /usr/bin/perl use warnings; use strict; use feature qw{ say }; use XML::LibXML; my @xmls = (<< '__XML1__', << '__XML2__'); <?xml version="1.0" encoding="utf-8" ?> <propfind xmlns="DAV:"> <propname/> </propfind> __XML1__ <?xml version="1.0" encoding="utf-8" ?> <D:propfind xmlns:D="DAV:"> <D:propname/> </D:propfind> __XML2__ for my $xml (@xmls) { my $xpc = 'XML::LibXML::XPathContext'->new; $xpc->registerNs('x', 'DAV:'); my $doc = 'XML::LibXML'->load_xml(string => $xml); say $xpc->find('count(//x:propname)', $doc); }
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Is it true that ... and ... are the same (semantically)?

        They both have a root node named "propfind" in the namespace "DAV:" with a child "propname" also in the namespace "DAV:". Which shortcut was used to assign that namespace does not matter.