The xml file is :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 - $!";
<?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&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&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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |