Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath query help with getting parent nodes

Reply
Thread Tools

XPath query help with getting parent nodes

 
 
mike@pmbtech.com
Guest
Posts: n/a
 
      01-05-2007
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-05-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      01-05-2007
* (E-Mail Removed) 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 · (E-Mail Removed) · 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/
 
Reply With Quote
 
mike@pmbtech.com
Guest
Posts: n/a
 
      01-05-2007
Thanks,
I was dancing all around it. the nested [] is what was tripping me up.

Martin Honnen wrote:
> (E-Mail Removed) 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/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
XPATH Query String - Finding Duplicate Nodes pg_11@rediffmail.com XML 2 12-25-2004 04:47 PM
XPATH Query String - Finding Duplicate Nodes pg_11@rediffmail.com XML 0 12-25-2004 04:38 PM



Advertisments