Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: XML::LibXML and Namespace… I don't get it

by tobyink (Canon)
on Jun 06, 2014 at 16:08 UTC ( #1089055=note: print w/replies, xml ) Need Help??


in reply to XML::LibXML and Namespace… I don't get it

The namespace is this bit:

xmlns="http://www.w3.org/1999/xhtml"

Not this bit:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

So you should be setting up your XPath context like this:

$xpc->registerNs( xml => "http://www.w3.org/1999/xhtml" );

That said, it's probably not a good idea to use the name "xml" for the XHTML namespace. Names beginning with those three letters are reserved for special purposes by the XML specification. So it's probably a better idea to use a different name:

$xpc->registerNs( h => "http://www.w3.org/1999/xhtml" );
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^2: XML::LibXML and Namespace… I don't get it
by ikegami (Pope) on Jun 06, 2014 at 16:49 UTC
    From Namespaces in XML,

    The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace.

    The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. It MUST NOT be declared . Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace. Element names MUST NOT have the prefix xmlns.

    All other prefixes beginning with the three-letter sequence x, m, l, in any case combination, are reserved. This means that:

    • users SHOULD NOT use them except as defined by later specifications

    • processors MUST NOT treat them as fatal errors.

      Thanks for confirming and in fact this was one of my 2 mistaks.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re^2: XML::LibXML and Namespace… I don't get it
by Skeeve (Parson) on Jun 06, 2014 at 17:04 UTC

    Thanks! I already noticed the stuff about the dtd in place of the namespace. Stupid mistake.

    That stupid mistake interfered with the second one you pointed out and ikegami confirmed.

    So using the correct namespace and another prefix than "xml" solved the problem.

    Thanks a lot!


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1089055]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2020-08-13 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (75 votes). Check out past polls.

    Notices?