Matching first set of elements with xpath...
Posted
by Ugo Enyioha
on Stack Overflow
See other posts from Stack Overflow
or by Ugo Enyioha
Published on 2010-03-26T18:05:30Z
Indexed on
2010/03/26
18:13 UTC
Read the original article
Hit count: 489
xpath
I have an xml document that looks like this.
<foo>
<bar type="artist"/> Bob Marley </bar>
<bar type="artist"/> Peter Tosh </bar>
<bar type="artist"/> Marlon Wayans </bar>
</foo>
<foo>
<bar type="artist"/> Bob Marley </bar>
<bar type="artist"/> Peter Tosh </bar>
<bar type="artist"/> Marlon Wayans </bar>
</foo>
<foo>
<bar type="artist"/> Bob Marley </bar>
<bar type="artist"/> Peter Tosh </bar>
<bar type="artist"/> Marlon Wayans </bar>
</foo>
I would like to construct an xpath that returns only the first set:
<bar type="artist"/> Bob Marley </a>
<bar type="artist"/> Peter Tosh </a>
<bar type="artist"/> Marlon Wayans </a>
How would one go about this? I have tried //bar[@type='artist']
but it's obvious there's more to this. Thanks in advance.
© Stack Overflow or respective owner