473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Tricky XPath query - Part 2

Hey all, I've attempted to simplify my question (or at least the XML
that is part of my example in my question):

I have the following XML:
<A>
<B><C><D>
I want to query the data in this node for the element B
</D></C><E>
I also want to query the data in this node for the element B
</E>
</B>
<B><!--Additional data for another B element-->
</B>
</A>

My idea is to do something like this:
---------------------------------------------------
Dim nav As XPathNavigator = doc.CreateNavigator()

Dim iterator As XPathNodeIterator

iterator = nav.Select("/A/B/C[D = '" + someVariable + "'] and /A/B[E =
'" + secondVar + "']")
---------------------------------------------------
Initially, both D and E fell under the same node or tag - so I just
used the code below:
iterator = nav.Select("/A/B/C[D = '" + someVariable + "' and E = '" +
anotherVar + "']")

But now they are at different levels in the node hierarchy (as in the
above example).

Thanks for any suggestions,
Novice
Nov 12 '05 #1
3 1338
Your question is still not clear. What node(s) do you expect to get back or
do you simply want to test that both those values exist under a particular B
element?

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Novice" <6t**@qlink.queensu.ca> wrote in message
news:b8**************************@posting.google.c om...
Hey all, I've attempted to simplify my question (or at least the XML
that is part of my example in my question):

I have the following XML:
<A>
<B><C><D>
I want to query the data in this node for the element B
</D></C><E>
I also want to query the data in this node for the element B
</E>
</B>
<B><!--Additional data for another B element-->
</B>
</A>

My idea is to do something like this:
---------------------------------------------------
Dim nav As XPathNavigator = doc.CreateNavigator()

Dim iterator As XPathNodeIterator

iterator = nav.Select("/A/B/C[D = '" + someVariable + "'] and /A/B[E =
'" + secondVar + "']")
---------------------------------------------------
Initially, both D and E fell under the same node or tag - so I just
used the code below:
iterator = nav.Select("/A/B/C[D = '" + someVariable + "' and E = '" +
anotherVar + "']")

But now they are at different levels in the node hierarchy (as in the
above example).

Thanks for any suggestions,
Novice

Nov 12 '05 #2
Hey all, I'll try to make my question a little more clear

I have the following XML
<A><B><C><D
I want to query the data in this node for the element
</D></C><E
I also want to query the data in this node for the element
</E></B><B><!--Additional data for another B element--></B></A

Let's say I want to get all the B elements/nodes returned to me that have the following text in the D element
I want to query the data in this node for the element

AN

the following text in the E element
I also want to query the data in this node for the element

My idea is to do something like this
--------------------------------------------------
Dim nav As XPathNavigator = doc.CreateNavigator(
Dim iterator As XPathNodeIterato
iterator = nav.Select("/A/B/C[D = '" + someVariable + "'] and /A/B[E = '" + secondVar + "']"
--------------------------------------------------
Initially, both D and E fell under the same node or tag - so I jus
used the code below
iterator = nav.Select("/A/B/C[D = '" + someVariable + "' and E = '" + anotherVar + "']"

But now they are at different levels in the node hierarchy (as in th
above example) and so the query immediately above will no longer work

Thanks
Novice
Nov 12 '05 #3
In actual fact, in the XML below
<A><B><C><D
I want to query the data in this node for the element
</D></C><C><D
I don't want this one
</D></C><E
I also want to query the data in this node for the element
</E></B><B><!--Additional data for another B element--></B></A

I will receive two query strings - one that is for element E and another that is for element D

If I find a match in element E (belonging to a B element), I would like to return all C elements in that B element that have a D element that matches. So in the example above, if I had the request for the text in node/element D
I want to query the data in this node for the element

and the request for the text in the node/element E
I also want to query the data in this node for the element

Then I would only return one C element
<C><D
I want to query the data in this node for the element
</D></C

However, I've tried to simplify my question and reduce my overall question to "how to make queries between different levels in the XML hierarchy"

Thanks
Novice
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
2
by: Novice | last post by:
Hi all, I've just changed the structure of my XML file and now I need to construct an XPathNavigator object that uses tags from two different levels in the XML file. For example: <someTag>...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to construct an XPath query against an XML document, for a requirement that I have. Below is the XML fragment: <SUBMISSIONS> <SUBMISSION YEAR="2004"> <MONTH...
5
by: tschulken | last post by:
I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml <S3Client> <Buttons>...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.