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>

In reply to How to use of meta characters in search string in XPath in perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.