How to select parent based on a child value via XPath?

Here is sample XML:

<Root>
   <A>
      <B>
         <C>Yes</C>
      </B>
   </A>
      :
   <A>
      <B>
         <C>No</C>
      </B>
   </A>
</Root>

There can be any # of nested <A> with values of either Yes or No. I would 
like to select <A> node(s) based on value of <C>. In pseudo code:

Give me all <A> where <C> = "Yes" (or "No). So far I was able to select all 
"Yes" (or "No") but these are <C> nodes and need their grandparents.
TIA 
0
Art1645 (139)
8/29/2007 6:38:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
488 Views

Similar Articles

[PageSpeed] 0

Art wrote:
> Here is sample XML:
> 
> <Root>
>    <A>
>       <B>
>          <C>Yes</C>
>       </B>
>    </A>
>       :
>    <A>
>       <B>
>          <C>No</C>
>       </B>
>    </A>
> </Root>
> 
> There can be any # of nested <A> with values of either Yes or No. I would 
> like to select <A> node(s) based on value of <C>. In pseudo code:
> 
> Give me all <A> where <C> = "Yes" (or "No). So far I was able to select all 
> "Yes" (or "No") but these are <C> nodes and need their grandparents.

In XPath, //A[descendant::C='Yes'] or possibly //C[.='Yes']/ancestor::A

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/

0
Peter
8/29/2007 10:25:22 PM
Reply:

Similar Artilces:

How to install UMDF-based class filter driver?
Hi, I used to have a WDM-based class filter driver and a setup application which calls the "SETUPAPI.DLL InstallHinfSection" with the INF DDInstall section passed into the function. Now I am trying to port the driver to UMDF-based version. I modified the INF as per WDK required, but I got an installation problem - the UMDF co-installer "WUDFUpdate_01009.dll" can't be triggered by using the setup application. However, installation via Device Manager with the INF is OK. How should I solve such problem? Appreciate your replies. what class are you ad...

Query-based list w/1 Exception
I've created a query based distribtuion list which works fine yet out of the 1000 or so mailboxes it gives me I'd like to exclude 10. Is there a way? (Basically I have checked only "Users with Exchange mailbox") Make those 10 recipients members of a distribution group, and add the following to the query: (&(your current query)(!memberOf=distinguished Name of the distribution group)) Alternatively, if there's a common value of a particular attribute like location/city/department, et al, use that to exclude them. -- Bharat Suneja MVP - Exchange www.zenprise.com ...

Combo box list selection based on earlier selection by user
HI, I have a form that has a combo box 1 (Product) that reads a the Product table and has a unique id attached to each product (RO#). There is a second combo box 2 that is RO#. Now what I would like to do is when a user selects a Product in combo box 1, the system should lookup the Product selected from combo box 1 and upload the corresponding RO# in the combo box 2 list. Now I am using both combo boxes as Unbound and in the combo box 2 I have the two columns Product and RO# - in the Criteria row of RO# I have the following: Like IIf([Forms]![xa_f_lookup]![RO#]=" ",[Forms]![x...

Run report on multi selected records.
I try to make a report for a custom entity that works like the Account Summary: let's say that it's Customer's Inquiry Summary for entity Customer's Inquiry I made the report so that I'm able to run the report on Customer's Inquiry Form. But when I select multi records in the list of Customer's Inquiry and run report, only one record is show in one page of the the report. I would like to have the selected records appear in the report with each record on each page. How can I do this? ...

Can't select objects in Excel 2007
I'm trying to create a form in Excel 2007, and although I can manipulate, copy & paste controls (check boxes, etc) I can't select multiple objects to align them, etc. I've checked on-line help (and have followed the instructions), and other websites, but no one seems to have indicated a problem. It is extremely cumbersome and I need a solution. Any ideas? Thanks in advance, Jim Berglund I know this is about a year too late, but it may help others who have stumbled across this page looking for similar help. On the Home tab, in the Editing group, click Find & Select....

Lot Selection not Showing when I select PO on Receiving Entry
Usually, the Lot selection screen would pop up when I select a PO at the Line Detail of the Receivings Entry, now it does not! And GP will let items post without a lot number! It seems as if a setting has changed. Any ideas anyone? Any help is appreciated. Thanks, R Are you sure the item is marked to track lots? This wiould be set item by item on the Item Maintenance Options window. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com &q...

Select contact then hangs
Hi, please help. I have a user that when she selects a contact using To: in a new email, after selecting 2, it closes outlook??. Spec is W2kSP4\office2k with all windows updates and office updates installed. Profile has been deleted and re-created, plus i have set up personal folders and moved contacts into there, and set that folder as a default, but makes no difference. Please help. ...

Selecting rows from various sheets
Hi all, I have several sheets with a few columns in each. One colum in each sheet has a unique value. Most of these unique values are th same in each sheet but not all. Is there any way that I can set up new sheet that will have the unique value in column 1 and th corresponding column values frommeach sheet beside it. For example Sheet 1 aa 1 1 1 bb 2 2 2 cc 3 3 3 Sheet 2 aa 4 4 cc 5 5 Result aa 1 1 1 4 4 bb 2 2 2 cc 3 3 3 5 5 Thanks alot, Sha -- sha ----------------------------------------------------------------------- shav's Profile: http...

null value pass from form into query
For some reason I can't seem to get this to work and was hoping posting here would speed up finding the resolution. I have a form that the users a specifying a value from based on a list box. The users press a button on the form after doing the selection and it executes a query with criteria based on the value from the field; the query is using [Forms]![frmBatchesNeedingIndexing]![Contract].[Value] as the critera. This works fine when a users specifies a value. The problem I'm experiencing is I need this list box to have the capability to have a null value passed to the que...

select text in Calendar
I'm working on a calendar in Publisher. I'm adding text into a cell by spacing down 1 point, then typing in 8 points. Doing fine until April. At that time, I can only select cells (whole days). It will not let me select the text. Help is no help. Any hints out there. Did I accidentally select something to do this? Bonnie Have you added a picture to the cell or a shape? If you have send it to the back, make the cell no fill and try again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "GoBonnieGo" <GoB...

Accessing SQL Server via MFC & ADO
Hello, I currently have two MFC applications that are accessing SQL Server via ADO. Everything works perfectly (it connects to SQL Server and runs the stored procedures and all), the only issue that I seem to be having is that everytime I rebuild and run the application, my firewall comes up saying that my apps need to connect to the net. There is no networking code in either of these apps, so I am guessing that somehow this is caused by me connecting to SQL Server? The server I am connecting to is local (on my machine), and will be local during deployment. My question is, how do I ge...

macro to filter data based on selected data
Hi, I am looking for a macro that requests input of a reference code and then a date and then filters the data in my spreadsheet based on this criteria. I am using excel 2007. Any help with this will be greatly appreciated. You can probably record a macro while doing it manually and then clean it up and add input boxes to ask the question or input your variable in a cell and use that. If all else fails, If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the ...

Link select with a blast
I have Win 7 Home Premium, x64. Quite often, when I select a link, a mouse pointer changes to a palm with a blast. I understand, the palm is the standard mouse pointer for link select, but what is the blast? What it indicates? -- Ilya Zeldes Fort Myers, Florida Hi Ilya, I suspect that this is being caused by a tracking program. Run something like Ad-Aware and see if it indicates a tracking company. If so, you can delete it, however, it might prevent you from accessing that particular website. Dave "Ilya Zeldes" wrote in message news:7A6FF9B1-5512-44...

Select Case in a Change Event
Hi, I am trying to use a worksheet Change Event to trap changes to specific columns. depending on which column is chnaged by the user, the value in another ciolumn will be altered; so, changes in either column O or P will update column Q, changes in either column T or U will update column V and changes in column Z or AA will update column AB. What I can't figure out is the Select Case bit (where I've got the shouted question below). Here's what I've put together, any comments would be much appreciated. Private Sub Worksheet_Change(ByVal Target As Range) ...

Counting number of records based on criteria
Hello, (Try again to get the question in the google-groups. Perhaps not pushed on the send button). For counting records as expression in a report in ms.access I'm using =count(*) which shows all records. Now I also want to know how many of them has registered a specific data in a specific field. I'm trying to use =count([Field1]="999") to count how many of the selection reported has registered data 999. This option isn't work. Can somebody give me the correct solution. thanks, Johan The 999 needs to go in the criteria for the query driving the...

Select Records based another table...
This may be very elementary, but i can't wrap my brain around it. I have tried to dummy it down as much as i can for myself, with plans of adapting it into something working. I have three tables that look like the following: Tbl 1: ProdID A B C 1 $1 $2 $3 2 $4 $5 $6 3 $7 $8 $9 Tbl 2: RmNum ProdID 1 3 1 2 2 1 2 2 Tbl 3: RmNum Style 1 A 2 C Relationships are: [tbl1 ProdID] ------ [tbl2 ProdID] [tbl2 RmNum] ...

Multi-Select List Box Does Not Retain Selected Items
I created an Outlook Form in 2003. But when I select items in the list box they do not remain select when I select another control on the form. Any suggestions? Did you bind the list box to a keywords field? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "kaykay" <anonymous@discussions.microsoft.com> wrote in message news:276dd01c4638d$bd5af590$a501280a@phx.gbl... > I created an Outlook Form in 2003. But when I select > items i...

Determining address of value type variables
How to get the address of(memory location) value type variables? GetHashCode() returns only value and not its address Thank you Regards Raj "Raj" wrote: > How to get the address of(memory location) value type variables? > > GetHashCode() returns only value and not its address > > Thank you > > Regards > Raj An address in memory and a hashcode have nothing to do with each other. You should rarely, if ever, need to get an address of any .net object. To get an address in memory, you need to use unsafe code and the "&a...

No Attribute error when trying to save an account with parent acco
I tried to add a parent account to an account form. The name of the parent account is displayed correctly in account form, but when I press Save or Save and Close button, I get "No attribute" error on the screen. The information about the parent account is not saved. I have made few customizations, but really don´t think that they cause this problem. That´s because as long as I don´t touch the parent account field, save function works correctly. Who can I locate the reason for this problem? Hi, Setting a parent account is a quite basic action which should work...

VBA
I am very new to VBA and access and have a question regarding a SELECT statement. I am going to run a select (recordset - so I can loop through and process each record) but on my SELECT I want to make sure I return at least 20 rows, otherwise I am going to change my WHERE clause to include more rows. Is there an easy way to do this or do I need to just do an inital SELECT COUNT(*) and then decide which WHERE clause to use?? Do you have an example I can look at? Thank you in advance! AJ On Fri, 14 Dec 2007 17:14:00 -0800, AJ <AJ@discussions.microsoft.com> wrote: I would not first ...

Using text in place of values
Hi there - I'm new to Excel but I can't figure out how to use text in place of numeric values. I'm building an invoicing worksheet - so one column indicates the hourly rate, the other lists the amount of time billed at that rate. So for example, in one column it says "Design" and in the next column it says 4.00 hrs. Design is billed at $35.00 per hour - so somehow I need to tell Excel that "Design" = $35.00 and then have it do the multiplication between the two cells. Any ideas? Thanks for your help! Gabe Silverman Gabe I would set up your tasks and thei...

Importing text to chart based on link to cell
I am attempting to link a cell from my spread sheet to a text box in my chart, but have been unable to do so. Does anyone know how or if this is possible. On Fri, 7 Nov 2003 12:59:29 -0800, Stephen <stephen.szyndrowski@telus.co= m> = wrote: > I am attempting to link a cell from my spread sheet to a > text box in my chart, but have been unable to do so. Does > anyone know how or if this is possible. Select the chart, then click in the formula bar (above the chart, next t= o = the little "fx"), type the equal sign, then click on the cell that you = wish to refe...

#VALUE!
I'm trying to get a percentage from the following formula c10/b10-1, the problem i'm facing is that c/10 & b10 are zero value - I just want to make it 0%. Any options? Thank you Try this... =IF(OR(B10=0,C10=0),0,C10/B10-1) -- Biff Microsoft Excel MVP "Kmtravel" <Kmtravel@discussions.microsoft.com> wrote in message news:1D3AD05F-DFD0-4676-848A-9FF86D2B94B8@microsoft.com... > I'm trying to get a percentage from the following formula c10/b10-1, the > problem i'm facing is that c/10 & b10 are zero value - I just want to ...

Drop down list quicker selection
We are using Excel 2003 We created a drop down list using the Data\Validation process, which works fine. When the arrow within a cell is clicked on to show the drop down list, how can you quickly select one of the many names in the list just by typing the first character of a name within the list. At the moment, we have to scroll up and down the list to select a particular name, which in itself isn't a problem, but slows down the process of finding the right name. Can the names within the list be alphabetically grouped when inputting the first character from the keyboard, and spee...

Recipient Policy-based Auto-Delete sending Read Receipits?
All, Based on some user reports, I think that a Recipient Policy-based auto- delete for messages older than x days is sending "negative" read receipts, eg: 1) User gets message with read receipt 2) User doesn't read message 3) Recipient Policy deletes message after x days, and sends the message sender a read receipt saying user has NOT read the message Is this possible? If it does happen, can we use the user's "never send read receipts" setting in Outlook to stop it? Is there a way to stop only the Recipient Policy from sending read receipts for all users, and ...