What is wrong with registerNs()?
my $dom = $parser->parse_file("book.xml"); my $root = $dom->documentElement(); my $xpc = XML::LibXML::XPathContext->new($root); $xpc->registerNs(xlink => "http://www.w3.org/1999/xlink") or die "Coul +dn't register Namespace - $!";
The xml file is :
<?xml version="1.0" encoding="UTF-8"?> <book:bookResource xmlns:xlink="http://www.w3.org/1999/xlink"> <book:book> <book:chapter id="bk111111ch1" type="CHAPTER"> <book:locator xlink:href="/book/isbn/979-0-1234-1111-1/book-part/chapt +er/bk111111ch1?releaseStatus=UNRELEASED" xlink:title="Photonic crysta +l light-emitting sources" xlink:type="locator" xmlns:xlink="http://ww +w.w3.org/1999/xlink"/> <book:locator xlink:href="/book/isbn/979-0-1234-1111-1/book-part/chapt +er/bk111111ch1?releaseStatus=UNRELEASED&amp;format=pdf" xlink:title=" +Photonic crystal light-emitting sources" xlink:type="locator" xmlns:x +link="http://www.w3.org/1999/xlink"/> <book:locator xlink:href="/book/isbn/979-0-1234-1111-1/book-part/chapt +er/bk111111ch1?releaseStatus=UNRELEASED&amp;format=epub" xlink:title= +"Photonic crystal light-emitting sources" xlink:type="locator" xmlns: +xlink="http://www.w3.org/1999/xlink"/> <book:meta doi="10.1088/bk111111ch1" firstPage="1-1" lastPage="1-118"> <book:author givenName="Roger" surname="Ebert"><book:affiliation xlink +:href="bk111111ch1af1" xlink:type="locator" xmlns:xlink="http://www.w +3.org/1999/xlink"/></book:author> <book:affiliation name="Cavendish Laboratory, University of Cambridge" +><book:locator xlink:href="bk111111ch1af1" xlink:type="locator" xmlns +:xlink="http://www.w3.org/1999/xlink"/></book:affiliation> </book:meta> </book:chapter> </book:book> </book:bookResource>

In reply to Not able to register namespace in XML::LibXML on Linux. by ravi06

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.