?
Solved

[XPATH] query problem with siblings

Posted on 2006-11-13
4
Medium Priority
?
535 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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 will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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