Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want replace the replace the XPath in print statement as below: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'); }
So that I will always get the value of title where the href tag contains "releaseStatus=RELEASED" only. The XML file is as follows:print $chapter_node->findvalue('locator[@href ="/*releaseStatus=RELEAS +ED"]/@title'); }
<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&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&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 |