#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
my $xml = XML::LibXML->load_xml(IO => *DATA);
my $root = $xml->documentElement;
my $chapter_node = $root->findnodes('book:chapter')->[0];
print $chapter_node->findvalue('./book:locator/@*') . "\n";
__DATA__
<book xmlns:book='b'> <!-- Namespace definition missing in the origina
+l data -->
<book:chapter id="bk444444ch1" type="CHAPTER">
<book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap
+ter/bk444444ch1?releaseStatus=RELEASED" xlink:title="Photonic crystal
+ light-emitting sources" xlink:type="locator" xmlns:xlink="http://www
+.w3.org/1999/xlink"/>
<book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap
+ter/bk444444ch1?releaseStatus=RELEASED&format=pdf" xlink:title="P
+hotonic crystal light-emitting sources" xlink:type="locator" xmlns:xl
+ink="http://www.w3.org/1999/xlink"/>
<book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap
+ter/bk444444ch1?releaseStatus=RELEASED&format=epub" xlink:title="
+Photonic crystal light-emitting sources" xlink:type="locator" xmlns:x
+link="http://www.w3.org/1999/xlink"/>
</book:chapter> <!-- Missing in the original data -->
</book>
Note the changes I made to your data. Maybe your $chapter_node contains something else?
|