473,386 Members | 1,799 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,386 software developers and data experts.

XPath query help with getting parent nodes

Hello,
I am new to XPATH and am having a hard time selecting some nodes.
I want to select all the record nodes where Status = 'Unprocessed' or
'Queued' (that part I can get) but additionally I only want the ones
where the Field/Fieldname ='ChangeType' and Field/Value = 'SN'
I have //ExtractInfo/Record[Status='UnProcessed' or
Status='Queued']/Field[Fieldname='ChangeType' and Value='SN'] but that
gets the field nodes, I need the record nodes.
Below is a snippet of the abbreviated XML doc:
<Extract>
<ExtractInfo>
<Status>UnProcessed</Status>
<Record>
<RecordNumber>1</RecordNumber>
<Status>UnProcessed</Status>
<Field>
<Fieldname>ChangeType</Fieldname>
<Value>SM</Value>
</Field>
</Record>
<Record>
<Record>
<RecordNumber>2</RecordNumber>
<Status>UnProcessed</Status>
<Field>
<Fieldname>ChangeType</Fieldname>
<Value>SN</Value>
</Field>
</Record>
<Record>
</ExtractInfo>
</Extract>

Any help would be graetly appreciated

Thanks

Jan 5 '07 #1
3 1879
mi**@pmbtech.com wrote:
I am new to XPATH and am having a hard time selecting some nodes.
I want to select all the record nodes where Status = 'Unprocessed' or
'Queued' (that part I can get) but additionally I only want the ones
where the Field/Fieldname ='ChangeType' and Field/Value = 'SN'
I have //ExtractInfo/Record[Status='UnProcessed' or
Status='Queued']/Field[Fieldname='ChangeType' and Value='SN'] but that
gets the field nodes, I need the record nodes.
//ExtractInfo/Record[
Status='UnProcessed' or Status='Queued' and
Field[Fieldname='ChangeType' and Value='SN']]

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 5 '07 #2
* mi**@pmbtech.com wrote in comp.text.xml:
>I am new to XPATH and am having a hard time selecting some nodes.
I want to select all the record nodes where Status = 'Unprocessed' or
'Queued' (that part I can get) but additionally I only want the ones
where the Field/Fieldname ='ChangeType' and Field/Value = 'SN'
You have to formulate these extra conditions as predicates like so:

//Record[ (Status = 'UnProcessed' or Status = 'Queued') and
Field[Fieldname = 'ChangeType' and Value = 'SN'] ]
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jan 5 '07 #3
Thanks,
I was dancing all around it. the nested [] is what was tripping me up.

Martin Honnen wrote:
mi**@pmbtech.com wrote:
I am new to XPATH and am having a hard time selecting some nodes.
I want to select all the record nodes where Status = 'Unprocessed' or
'Queued' (that part I can get) but additionally I only want the ones
where the Field/Fieldname ='ChangeType' and Field/Value = 'SN'
I have //ExtractInfo/Record[Status='UnProcessed' or
Status='Queued']/Field[Fieldname='ChangeType' and Value='SN'] but that
gets the field nodes, I need the record nodes.

//ExtractInfo/Record[
Status='UnProcessed' or Status='Queued' and
Field[Fieldname='ChangeType' and Value='SN']]

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 5 '07 #4

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
1
by: david_b_mcconnell | last post by:
Hi, I am having a problem using XPath when I validate Xml documents with a schema. Basically what happens is that an XPath query doesn't return the nodes I require if a schema is used to validate...
4
by: C# newbie | last post by:
Hi group, I've written a program which uses this XPath query: //* as you better know, it finds and locates "SomeString" under any path within an xml file. The thing is that I don't know...
1
by: Dave | last post by:
Is it possible to get <codes><code id="4"><name>abc</name></code></codes from the XML below in single SelectSingleNode/xPath expression step OR is going to have to be a multi=step process of...
1
by: jeffreyv | last post by:
Hi! Here's a XML reprensenting a company. I would like to make a XPath query that gives me all the employees that are Programmer or Analyst and have 5 years of experience. I did the following...
10
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
4
by: cgaden | last post by:
Hi everyone, I have a problem that I've been trying to figure out for a while but I just can't seem to get it right. I have the following XML fragment: <Page ID="x1" Schema="Folder"> -<Page...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.