Solved

[XPATH] query problem with siblings

Posted on 2006-11-13
4
528 Views
Last Modified: 2012-06-21
<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?
0
Comment
Question by:grexx
  • 3
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
ID: 17936423
Hi grexx,

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

Cheers!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17936429
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
 
LVL 1

Author Comment

by:grexx
ID: 17936848
Thanks Gertone! I see that I need to dive into XPATH a bit more.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17936896
welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now