XML ファイルを読み込んでいて、"print" の XPath を "@href="*?releaseStatus=RELEASED" に置き換えて、インスタンスの最初の出現を取得するためにジェネリックにする必要があります.どうすればそれを達成できますか?
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file("type_book.xml");
for my $chapter_node ($doc->findnodes('/book/contents'))
{
print $chapter_node->findvalue('locator[@href ="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releaseStatus=RELEASED"]/@title');
}
XML ファイル:
<book>
<contents>
<locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1? releaseStatus=RELEASED" role="http://www.abc.org/roles/book-part-locator" title="Photonic crystal light-emitting sources">
</locator>
<locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releaseStatus=RELEASED&format=pdf" role="http://www.abc.org/roles/book-part-pdf-locator" title="Photonic crystal light-emitting sources">
</locator>
<locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releaseStatus=RELEASED&format=epub" role="http://www.abc.org/roles/book-part-epub-locator" title="Photonic crystal light-emitting sources">
</locator>
</contents>
</book>