Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to get value of an element if it contains a part of the search string in XPath.
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-4 +444-1000-17/book-part/chapter/bk444444ch1?releaseStatus=RELEASED"]/@t +itle'); }
I want replace the replace the XPath in print statement as below:
print $chapter_node->findvalue('locator[@href ="/*releaseStatus=RELEAS +ED"]/@title'); }
So that I will always get the value of title where the href tag contains "releaseStatus=RELEASED" only. The XML file is as follows:
<book> <contents> <locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk44444 +4ch1?releaseStatus=RELEASED" role="http://www.iop.org/roles/book-part +-locator" title="Photonic crystal light-emitting sources"> </locator> <locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk44444 +4ch1?releaseStatus=RELEASED&amp;format=pdf" role="http://www.iop.org/ +roles/book-part-pdf-locator" title="Photonic crystal light-emitting s +ources"> </locator> <locator href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk44444 +4ch1?releaseStatus=RELEASED&amp;format=epub" role="http://www.iop.org +/roles/book-part-epub-locator" title="Photonic crystal light-emitting + sources"> </locator> </contents> </book>

Replies are listed 'Best First'.
Re: How to use of meta characters in search string in XPath in perl
by daxim (Curate) on Jul 14, 2013 at 19:51 UTC
Re: How to use of meta characters in search string in XPath in perl
by Anonymous Monk on Jul 14, 2013 at 23:37 UTC