XPath Query path to extract a value from a preceding-sibling

K

kfrost

Hello,

I'm rephrasing a previous post due to no response. I'm trying to figure out
the xpath syntax to get the values from preceding-sibling and
Following-siblings

Say I have a data connection and each set of records returned has a TripID
field. I want to assign a variable the value of the TripID of the
preceding-Sibling or following-Sibling.

Anybody know of how to do this? Here is the syntax to get the current nodes
TripID value.

xdXDocument:GetDOM("Trips")/dfs:myFields/dfs:dataFields/d:Trips/@TripID

I would think it would have been something along the lines of
xdXDocument:GetDOM("Trips")/dfs:myFields/dfs:dataFields/d:Trips/../preceding-sibling/@TripID

But I can't figure it out.

Thanks.

kris
 
J

Jason

What about structuring your schema so that each Trip may contain a SubTrip,
recursively? Then you jsut reference the parent.

Not to say that what you're asking about can't be done.
 
K

kfrost

Ok, I've made very little progress in my spare time but I've decided to just
do this through VB.Net code.

To get the TripID value from the Main Data Object in the TripDetails view, I
use the following.

Dim objNextTripElement As IXMLDOMElement

Dim objCurrentTripElement As IXMLDOMElement =
thisXDocument.DOM.selectSingleNode("//Trips")
gstrTripID = objCurrentTripElement.getAttribute("TripID")

Now I'm trying to figure out how to access the TripID value from a Secondary
data source named Trips which is populated from the view named Main.

I thought this would work:

Dim objTripsDoc As IXMLDOMDocument = thisXDocument.GetDOM("Trips")
Dim objTripsElem As IXMLDOMElement = objTripsDoc.selectSingleNode("//Trips")

Dim strID As String = objTripsElem.getAttribute("TripID")

The first statement above works however the selectSingleNode in the seconde
statement immediately above yields nothing and objTripsElem keeps a value of
Nothing.

Any ideas?
 
K

kfrost

Here's what I've have up until now.

P.S.

What I have working so far. Not sure it's optimal but to go to the first
record, the following syntax appears to work.

xdXDocument:GetDOM("Trips")/dfs:myFields/dfs:dataFields/d:Trips[preceding::node()]/@TripID

To go to the last, the following works
xdXDocument:GetDOM("Trips")/dfs:myFields/dfs:dataFields/d:Trips[last()]/@TripID

Ok, the following code for next record works the first time the button is
clicked. Meaning the first time it's clicked, the next record will display.
However any subsequent clicks, nothing happens.

xdXDocument:GetDOM("Trips")/dfs:myFields/dfs:dataFields/d:Trips/following-sibling::*[1]/@TripID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top