Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Attributes cannot have attributes, they're attributes not elements

xpather.pl can help you

$ perl xpather.pl ravi06.xml /book:bookResource/book:book/book:meta/book:title/book:subTitle # posy /book:bookResource[1]/book:book[1]/book:meta[1]/book:title[1]/book:sub +Title[1] # star /*[ name() = "book:bookResource" and position() = 1 ] /*[ name() = "book:book" and position() = 1 ] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover. +gif" and @doi = "10.1088" and @publicationDate = " 2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:title" and position() = 1 and @title = "Lattice dyn +amics" ] /*[ name() = "book:subTitle" and position() = 1 ] # rats /book:bookResource[1] /book:book[1] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover +.gif" and @doi = "10.1088" and @publicationDate = "2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:title" and position() = 1 and @title = "Lattice dy +namics" ] /book:subTitle[1] # "content" Book 17 ------ /book:bookResource/book:book/book:meta/book:isbn[1] # posy /book:bookResource[1]/book:book[1]/book:meta[1]/book:isbn[1] # star /*[ name() = "book:bookResource" and position() = 1 ] /*[ name() = "book:book" and position() = 1 ] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover. +gif" and @doi = "10.1088" and @publicationDate = " 2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 1 and @isbn = "979-0-4444-10 +00-17" and @type = "epub" ] # rats /book:bookResource[1] /book:book[1] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover +.gif" and @doi = "10.1088" and @publicationDate = "2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 1 and @isbn = "979-0-4444-1 +000-17" and @type = "epub" ] # "content" ------ /book:bookResource/book:book/book:meta/book:isbn[2] # posy /book:bookResource[1]/book:book[1]/book:meta[1]/book:isbn[2] # star /*[ name() = "book:bookResource" and position() = 1 ] /*[ name() = "book:book" and position() = 1 ] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover. +gif" and @doi = "10.1088" and @publicationDate = " 2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 2 and @isbn = "979-0-4444-20 +00-2" and @type = "ppub" ] # rats /book:bookResource[1] /book:book[1] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover +.gif" and @doi = "10.1088" and @publicationDate = "2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 2 and @isbn = "979-0-4444-2 +000-2" and @type = "ppub" ] # "content" ------ $ $ $ $ $ perl xpather.pl ravi06.xml //*[@isbn] /book:bookResource/book:book/book:meta/book:isbn[1] # posy /book:bookResource[1]/book:book[1]/book:meta[1]/book:isbn[1] # star /*[ name() = "book:bookResource" and position() = 1 ] /*[ name() = "book:book" and position() = 1 ] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover. +gif" and @doi = "10.1088" and @publicationDate = " 2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 1 and @isbn = "979-0-4444-10 +00-17" and @type = "epub" ] # rats /book:bookResource[1] /book:book[1] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover +.gif" and @doi = "10.1088" and @publicationDate = "2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 1 and @isbn = "979-0-4444-1 +000-17" and @type = "epub" ] # "content" ------ /book:bookResource/book:book/book:meta/book:isbn[2] # posy /book:bookResource[1]/book:book[1]/book:meta[1]/book:isbn[2] # star /*[ name() = "book:bookResource" and position() = 1 ] /*[ name() = "book:book" and position() = 1 ] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover. +gif" and @doi = "10.1088" and @publicationDate = " 2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 2 and @isbn = "979-0-4444-20 +00-2" and @type = "ppub" ] # rats /book:bookResource[1] /book:book[1] /*[ name() = "book:meta" and position() = 1 and @coverImage = "/cover +.gif" and @doi = "10.1088" and @publicationDate = "2016-12-01" and @issn = "1111-222X" and @collectionId = "0001" ] /*[ name() = "book:isbn" and position() = 2 and @isbn = "979-0-4444-2 +000-2" and @type = "ppub" ] # "content" ------ $
//*[ name() = "book:isbn" and @isbn and @type = "ppub" ]

In reply to Re: How do i get value of an element if the next elememnt has specific value in XML::LibXML using Xpath? by Anonymous Monk
in thread How do i get value of an element if the next elememnt has specific value in XML::LibXML using Xpath? by ravi06

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (10)
    As of 2014-10-21 08:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (98 votes), past polls