[XPATH] query problem with siblings

<data>

<record id="243">XTFC</record>
<record id="634">ABCD</record>
<record id="734">FTGD</record>
<record id="933">VCFG</record>
<record id="352">QDEW</record>

</data>

I'm a bit lost. If I take the previous xml data, how can I get the following-sibling of the element with @id="734"?  Using /data/following-sibling::record[@id='734'] doesn't work obviously, as it takes out that one record with id=734, and that sub-recordset doesn't have any siblings.

I could loop through all records until I find the right id, and then I can use the following-sibling, like below. I would have to do this twice, for the preceding-sibling as well.

<xsl:variable name="next">
      <xsl:for-each select="/data/record">
            <xsl:if test="@id='734'"><xsl:value-of select="following-sibling::*"/></xsl:if>
      </xsl:for-each>
</xsl:variable>

Isn't there a more direct way?
LVL 1
grexxAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
Hi grexx,

/data/record[@id='734']/following-sibling::record[1]

Cheers!
0
 
Geert BormansInformation ArchitectCommented:
grexx,

you need to follow a path
so first follow the path to the record with @id = 734
then step on the following-sibling axis, pick record
and use the first [1], if you only want one

cheers

Geert
0
 
grexxAuthor Commented:
Thanks Gertone! I see that I need to dive into XPATH a bit more.
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
All Courses

From novice to tech pro — start learning today.