Tricky XPath query

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>
  <innerTagA>
    <innerInnerTagA>
      <innerInnerInnerTagA>
        Some Data That Belongs Here
      </innerInnerInnerTagA>   
      <innerInnerInnerTagB>
        Some Data that Belongs More Specifically Here
      </innerInnerInnerTagB>   
    </innerInnerTagA>
    <innerInnerTagB>
      <innerInnerInnerTagZ>
        This Data should really go here
      </innerInnerInnerTagZ>    
    </innerInnerTagB>
  </innerTagA>


  <innerTagA>
    <innerInnerTagA>
      <innerInnerInnerTagA>
        This is another node with some Data That Belongs Here
      </innerInnerInnerTagA>   
      <innerInnerInnerTagB>
        Still another node with some Data that Belongs More
Specifically Here
      </innerInnerInnerTagB>   
    </innerInnerTagA>
    <innerInnerTagB>
      <innerInnerInnerTagZ>
        Another Node with the data that should really go here
      </innerInnerInnerTagZ>    
    </innerInnerTagB>
  </innerTagA>
</someTag>

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

Dim iterator As XPathNodeIterator

iterator = nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB
= '" + someVariable + "'] and
/someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVar
+ "']")
---------------------------------------------------
Initially, both innerInnerInnerTagB and innerInnerInnerTagZ fell under
the same node/tag - so I just used the code below:

iterator = nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB
= '" + someVariable + "' and innerInnerInnerTagZ = '" + anotherVar +
"']")

Will this XPath query work:
"/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB = '" +
someVariable + "'] and
/someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVar
+ "']"

AND/OR
is there a better way of formulating the query?

Thanks,
Novice
0
6tc1 (3)
4/15/2004 7:17:30 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
688 Views

Similar Articles

[PageSpeed] 14

It's hard to tell what you are trying to do and the format of your XML file
is hard to read. Can you simplify the XML file and describe what elements
you want to access? Some of the queries you wrote probably don't do what you
think but since I'm not sure what you want to do I can't be a 100% sure.

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

"Novice" <6tc1@qlink.queensu.ca> wrote in message
news:b80e4a77.0404151117.5b64114d@posting.google.com...
> 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>
>   <innerTagA>
>     <innerInnerTagA>
>       <innerInnerInnerTagA>
>         Some Data That Belongs Here
>       </innerInnerInnerTagA>
>       <innerInnerInnerTagB>
>         Some Data that Belongs More Specifically Here
>       </innerInnerInnerTagB>
>     </innerInnerTagA>
>     <innerInnerTagB>
>       <innerInnerInnerTagZ>
>         This Data should really go here
>       </innerInnerInnerTagZ>
>     </innerInnerTagB>
>   </innerTagA>
>
>
>   <innerTagA>
>     <innerInnerTagA>
>       <innerInnerInnerTagA>
>         This is another node with some Data That Belongs Here
>       </innerInnerInnerTagA>
>       <innerInnerInnerTagB>
>         Still another node with some Data that Belongs More
> Specifically Here
>       </innerInnerInnerTagB>
>     </innerInnerTagA>
>     <innerInnerTagB>
>       <innerInnerInnerTagZ>
>         Another Node with the data that should really go here
>       </innerInnerInnerTagZ>
>     </innerInnerTagB>
>   </innerTagA>
> </someTag>
>
> My idea is to do something like this:
> ---------------------------------------------------
> Dim nav As XPathNavigator = doc.CreateNavigator()
>
> Dim iterator As XPathNodeIterator
>
> iterator =
nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB
> = '" + someVariable + "'] and
> /someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVar
> + "']")
> ---------------------------------------------------
> Initially, both innerInnerInnerTagB and innerInnerInnerTagZ fell under
> the same node/tag - so I just used the code below:
>
> iterator =
nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB
> = '" + someVariable + "' and innerInnerInnerTagZ = '" + anotherVar +
> "']")
>
> Will this XPath query work:
> "/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB = '" +
> someVariable + "'] and
> /someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVar
> + "']"
>
> AND/OR
> is there a better way of formulating the query?
>
> Thanks,
> Novice


0
dareo (72)
4/16/2004 1:08:19 AM
I will try to reduce the complexity of my question
For example
<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

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 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

Thanks for any suggestions
Novic

    
     ----- Dare Obasanjo [MSFT] wrote: ----
    
     It's hard to tell what you are trying to do and the format of your XML fil
     is hard to read. Can you simplify the XML file and describe what element
     you want to access? Some of the queries you wrote probably don't do what yo
     think but since I'm not sure what you want to do I can't be a 100% sure
    
     --
     This posting is provided "AS IS" with no warranties, and confers no rights
    
     "Novice" <6tc1@qlink.queensu.ca> wrote in messag
     news:b80e4a77.0404151117.5b64114d@posting.google.com..
     > Hi all, I've just changed the structure of my XML file and now I nee
     > to construct an XPathNavigator object that uses tags from tw
     > different levels in the XML file
     >> For example
     >><someTag>><innerTagA>><innerInnerTagA>><innerInnerInnerTagA>>         Some Data That Belongs Her
     ></innerInnerInnerTagA>><innerInnerInnerTagB>>         Some Data that Belongs More Specifically Her
     ></innerInnerInnerTagB>></innerInnerTagA>><innerInnerTagB>><innerInnerInnerTagZ>>         This Data should really go her
     ></innerInnerInnerTagZ>></innerInnerTagB>></innerTagA>>>><innerTagA>><innerInnerTagA>><innerInnerInnerTagA>>         This is another node with some Data That Belongs Her
     ></innerInnerInnerTagA>><innerInnerInnerTagB>>         Still another node with some Data that Belongs Mor
     > Specifically Her
     ></innerInnerInnerTagB>></innerInnerTagA>><innerInnerTagB>><innerInnerInnerTagZ>>         Another Node with the data that should really go her
     ></innerInnerInnerTagZ>></innerInnerTagB>></innerTagA>></someTag>>> My idea is to do something like this
     > --------------------------------------------------
     > Dim nav As XPathNavigator = doc.CreateNavigator(
     >> Dim iterator As XPathNodeIterato
     >> iterator 
     nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTag
     > = '" + someVariable + "'] an
     > /someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVa
     > + "']"
     > --------------------------------------------------
     > Initially, both innerInnerInnerTagB and innerInnerInnerTagZ fell unde
     > the same node/tag - so I just used the code below
     >> iterator 
     nav.Select("/someTag/innerTagA/innerInnerTagA[innerInnerInnerTag
     > = '" + someVariable + "' and innerInnerInnerTagZ = '" + anotherVar 
     > "']"
     >> Will this XPath query work
     > "/someTag/innerTagA/innerInnerTagA[innerInnerInnerTagB = '" 
     > someVariable + "'] an
     > /someTag/innerTagA/innerInnerTagB[innerInnerInnerTagZ = '" + secondVa
     > + "']
     >> AND/O
     > is there a better way of formulating the query
     >> Thanks
     > Novic
    
    
     
0
Utf
4/16/2004 5:01:09 PM
Reply:

Similar Artilces:

Select a query showing only selective post codes relating a relevant postal area
Hi please could you help as i would like to run a query only selecting relevant post codes from my database. The post codes i would like to select are from ST1 to ST4, ST6 to ST7. Thank you spending time to help this issue Chedd -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200912/1 I assume that those are the starting three characters of the post code and that the next character is a space. You could try a query using the criteria Between "ST1" and "ST4 zzzzzz" OR Between "ST6" and ...

CRM query a view
Ill explain it, you tell me what im doing wring.... I want to write a custom page for crm that loads up in an IFrame. Its in a tab on the CASE window. it is SAPOSE to query the "FilteredTask" view and return all the tasks for that case. I pass it the case ID(guid) no problem there.. I can query tables no problem there either, but when it comes to querying the view (filteredTask) if returns empty. The WHOLE point of this is to have a page that i can print out with a signature line on the bottom that conatins account information (account name address, etc), case (incident) inf...

Error Exporting Access Query Results to Excel
I'm having 2 different problems exporting query results from Access to Excel (Office 2007). Problem 1: I do what I've always done, in Access VBA get ADO recordset from query results, instantiate Excel, get a range object, use the range object's CopyFromRecordset method. This has always worked in the (pre-Office 2007) past for me. It is much easier than iterating records and columns and assigning values to cells. Now, I get an error -2147467259 Automation Error Unspecified Error. I'm guessing this is because 2 of my recordset fields are pictures in Attach...

Append Query Re-run
Hi, I'm not sure if I'm on the right track. I have a MainForm and SubForm. When tab to end of MainForm, SubForm is populated through an append query. Works very well. Here is my problem. Let's say I have 5 questions and possible answers. When the append query runs, I see the 5 questions and possible answers, I select the participant's response and all is fine. BUT If I add other question(s) to the questions/answers table and scroll to an existing ppt's data, I only see the initial 5 questions, answers, responses. (New ppts are no problem, the append query run...

Percentage query
tblid name ordered_bit 1 A 1 2 A 0 3 A 1 4 A 0 desired result: name ordered_bit A 50 /*50 is the percentage (2/4)*/ Try: select [name] , sum (cast (ordered_bit as float)) / cast (count (*) as float) * 100.0 as ordered_bit from MyTable group by [name] -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com...

tricky program
i have just started working on this one, i need to find the smallest out of a selected number of numbers, i cant use if forever, and i need, a way to compare numbers as they are entered, and, the problem i ahve been having is that the number hm to signify how many input's will be taken keeps getting off track, and tips. #include <stdio.h> int main() { int total, a, i; float average = 0.0f; int hm; int counter; int clone; int number1; int number2; a = 1; total = 0; counter = 0; /*numbers smallest out of all of them */ while (a == 1) { printf("enter how man...

XPath help #2
Hi, I'm trying to use the XMLDataSource and DataList controls in Visual Web Developer Express (VB.Net) to present the following rss file in a web application. The problem lies in that I want to just select items (title, description and link) that are in the 'april' category. Can anyone help me with an XPath expression (or another way) of achieving this? Thanks. <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <channel> <copyright>Copyright 2007</copyright> ...

Tricky Autoreply
Hi I have set auto reply for a user, username is test (outlook rule – have server reply using), gave the user “test” send on behalf “user1.” In the From filed for the auto reply I am entering “user1”, but exchange is not accepting this rule and disabling it. I want the autoreply to be set on “test” user mailbox but going out from “user1”. Any ideas ?? -- Nawar Aljanabi MCSE NT/2000/2003,MCSA 2003 +M,CCNA On Tue, 9 Aug 2005 17:37:27 -0700, "Nawar75" <Nawar75@discussions.microsoft.com> wrote: >Hi > >I have set auto reply for a user, username is test (outloo...

Query Expression !
If have a column EmailAlert that contain 0 & -1 can I have an expression if EmailAlert = -1 "e" otherwise Nothing Thanks for any help..Bob On Thu, 10 Jan 2008 12:31:24 +1300, Bob V wrote: > If > have a column EmailAlert that contain 0 & -1 > can I have an expression if EmailAlert = -1 "e" otherwise Nothing > Thanks for any help..Bob Yes.In a query? NewColumn:IIf([EmailAlert]=-1,"e","") -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail ...

Query wizard problem...
I can't get the query wizard to show the columns from an Access database. I get as far as showing the tree view of all the tables, but the tables won't expand to pick columns. I've reinstalled Excel, and I've checked google and the knowledge base... Anyone have any ideas? Thanks! ...

excel: tricky formula/function question
howdy, all :) maybe someone can help me. i have an interesting "problem" and maybe someone has the answer. i am using excel. i am trying to figure out a formula/function which can convert a small set of numbers into a different set of numbers without manually using the "sort" function. here is an example: i have one column of seven rows with the following values: x 31.5 x 32.0 34.1 x 29.5 i want to convert that into a different column, using formulas/functions so that the new column reads: 31.5 32.0 34.1 29.5 (blank) (blank) (blank) basically, i want to take one colu...

Refreshable web query problem
I have copied some stock info from the web and pasted it into Excel 2003. According to the help, when I click on the paste options, I should have 3 options, one of which is to create a refreshable web query. I only get 2: keep souce formatting or match destination formatting. There is nothing about the refreshable web query! Why? What's going wrong?! ...

tricky formatting Q (perhaps not so tricky)
.......this has been driving my wife and i crazy......but it's probably easy stuff for some of you. we have a list of currency amounts....$23.61, $54.67, $110.00, $54.30 in place of those numbers, what we would like are: 00002361, 00005467, 00011000, 00005430 so basically wanting to have an eight digit number, with zeros preceeding the point that the number is displayed such that it is the last X number of places to complete the 8 digit requirement) is there a way to first do a check for the length of the currency number....length as in number of places......and then return the ze...

Query Refresh
I have a worksheet that has an external data source that refreshes automatically. Each time a user opens this workbook, they receive a dialog prompting whether or not they trust the source of the workbook. Their option is to Enable automatic refresh or disable automatic refresh (default). I dont want this to appear. The worksheet should automatically, without user intevention, enable auto refresh. How do I do this? Thanks Mike ...

Unwanted info in query
I have a Personnel database that I have created queries from, so as to show relevant information for certain data I need to collect and show. However there seems to be a problem, for example I would like to base a query on staff type (we have paid, volunteer and placement), I need to be able to show only paid, only volunteer etc. However even if I only select Volunteer for the tables I want included in my query - it shows all the names. What am I doing wrong!? Please copy and post the SQL of your query. (Possibly unneeded instructions follow) Open the query Select View:Sql from the M...

This is a tricky one #4
Does anybody else have any ideas for this problem -- gymba ----------------------------------------------------------------------- gymbag's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1622 View this thread: http://www.excelforum.com/showthread.php?threadid=27636 let'ssay you want to display the cell value of D28 on sheet2 in the cell A26 of this sheet: 1-click the cell A26 2-give the formula like this : =sheet2!D28 or 1-click the cell A26 2-type = and then activate sheet2 and click on cell D28 3-press Enter just like that! "gymbag" wrote: ...

Tricky problem?
Hi Is there a way to enter 2 pieces of data in one cell. Such as ....... Cell 1 Cell 2 3 4 Cell 5 John Smith Address City State (123) 456-7890 (123) 456-7890 I'd like to enter two phone numbers into one cell. Possible? Thanks Bill Type in the first phone number, hold down alt and press enter, type in the second phone number -- Regards, Peo Sjoblom "Bill Fitzgerald" <wmfitzgerald@comcast.net> wrote in message news:PbKdnTAddoLQ8ViiRVn-gQ@comcast.com... > H...

Combining Query Results
I am using an Access table to track sports schedules and games results. I have created queries that total the wins for each team, another that totals the losses and another for ties. I would like to bring these queries together to get what amounts to the league standings. Really I just need to add the losses count and the ties count to the wins query. Each of these values (wins, losses and ties) is based on a Count field in the respective query. Any help would be appreciated. Thanks in advance. Bob Mullen Care to share your table structure. Or at least the three queries. If your s...

Passing Query Prompt to Report
Hello. I am using Access 2007 and need some assistance with a report. The report is based on a select query that prompts for a date range. In the report is a graph that is also associated with the same query. The graph changes based on the dates selected. When the report is run the user is prompted to enter the date ranges twice. I think I understand why....because the query is called once for the main report and once for the graph. What do I need to do to avoid being prompted twice. SIDE NOTE: I can avoid the duplicate prompts by removing the Record Source for the main report ...

Append Query
I am trying to append data from tblitemline to tblitemlist. I only want to append new records. The unique field is ListID. I want to append 4 fields total. I can't get it to limit it to new records. Any help would be appreciated. Thanks! Show us the SQL. Open the query in design view. Next go to View, SQL View and copy and past it here. Information on primary keys and relationships would be a nice touch too. -- Jerry Whittle, Microsoft Access MVP Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder. "PPCO" wrote: > I am trying to append data from tblit...

Running Sum in Union Query?
Hello, I have created a Union Query to consolidate results from separate queries, each one of which represents results for a single month: SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth1Total UNION SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth2Total UNION SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth3Total; etc. This works very well for showing me monthly revenues vs. costs. However, I would also like to be able to create a similar Union Query that shows a running sum of the monthly revenue and costs. (Note: for reasons I won't get into here, I h...

Need help with Tricky SQL statement.
Give the business rules below. How can I obtain the desire results. Thank you so much in advance. SQL 2005 IF OBJECT_ID('Tempdb.dbo.#t', 'u') IS NOT NULL DROP TABLE #t GO CREATE TABLE #t ( LoanId INT NULL, Reviewedby VARCHAR(10) NULL, TaxesDueby1 VARCHAR(10) NULL, TaxesDueby2 VARCHAR(10) NULL, TaxesDueby3 VARCHAR(10) NULL, TaxesDueby4 VARCHAR(10) NULL ) GO INSERT #t VALUES (100003, 'John', 'John', 'Lisa', '', '') go SELECT * FROM #t; go LoanId ...

Namespaces & .NET XPaths
Just out of interest - is there an easier/quicker way to retrieve values via Xpath when namespaces are used? At the moment I seem to need a lot more lines of code to do something I thought was fairly standard? Of course I can just wrap the calls up into a helper function but was wondering if there was an easier way... XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("xs", http://mynamespace.com); node = doc.SelectSingleNode("//xs:person",nsmgr); ... pluck from node... OR XmlNamespaceManager nsmgr = new XmlNam...

Queries-Based Distribution group
Hello Everyone, Is it possible to use Queries-Based Distribution group functionnality in environment builded from Windows 2000 Activer Director and MS Exchange 2003 ? If nof, how I can deny users from my exchange organization send emails to all users in me organization ? Please, advice me Rgds, Robert Robert: I have never tried this combination to get QB distribution groups to work, but I think you can. Here is a really good article that explains their usage: http://www.msexchange.org/tutorials/Query_Based_Distribution_Groups.html You can always restrict the maximum number...

Combining query and table
Well, I have a table with fields like Quantity Borrowed and Quantity Returned. I have a query with a field QuantityAvailable which is calculated based on some formula... So, problem is I want to build a subform consists of this table and query together yet user can enter themselves the QuantityReturned and next field is the QuantityAvailable showed... How? -- Message posted via http://www.accessmonster.com Hey! Thanks for the idea... But, I have created the query and appended it in my form. It can works but it cannot automatically update as I enter the value in other fields.Any solution f...