My XML is
<row>
<entry>1.</entry>
<entry>foo</entry>
<entry>morefoo</entry>
</row>
<row>
<entry>2.</entry>
<entry>2foo</entry>
<entry>2morefoo</entry>
</row>
This is not wellformed XML document. A well-formed XML document must have exactly one top-level element. I will use the following (corrected to be well-formed) XML document:
<rows>
<row>
<entry>1.</entry>
<entry>foo</entry>
<entry>morefoo</entry>
</row>
<row>
<entry>2.</entry>
<entry>2foo</entry>
<entry>2morefoo</entry>
</row>
</rows>
How do i go about selecting the value
of only the first 'entry' tag?
/*/row/entry[1]
The above selects the first entry
element-child of every row
element.
/*/row[1]/entry[1]
The above selects the first entry
element-child of the first row
element in the document.
/*/row[2]/entry[1]
The above selects the first entry
element-child of the second row
element in the document.
(//entry)[1]
The above selects the first entry
element in the whole document.
//entry[1]
Note that this is different from the previous expression: this selects every entry
element in the document, which is the first entry
-child of its parent.