Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Selecting a node with child and parent condition.

Reply
Thread Tools

Selecting a node with child and parent condition.

 
 
okaissi79@gmail.com
Guest
Posts: n/a
 
      09-11-2007
<DeliverySchedule>
<Header>
<DistributorCode>MC</DistributorCode>
<TransmissionDate>2007-01-02</TransmissionDate>
<TransmissionTime>14:02:00.000</TransmissionTime>
</Header>
<Detail>
<StoreDelivery>
<SiteNum>001507</SiteNum>
<DSchedule>
<Order>
<Date>2007-09-02</Date>
<Time>08:02:01.000</Time>
</Order>
<Delivery>
<Date>2007-09-03</Date>
<Time>06:12:02.000</Time>
</Delivery>
</DSchedule>
<DSchedule>
<Order>
<Date>2007-09-04</Date>
<Time>08:02:03.000</Time>
</Order>
<Delivery>
<Date>2007-09-05</Date>
<Time>06:12:04.000</Time>
</Delivery>
</DSchedule>
</StoreDelivery>
<StoreDelivery>
<SiteNum>001510</SiteNum>
<DSchedule>
<Order>
<Date>2007-09-02</Date>
<Time>08:02:05.000</Time>
</Order>
<Delivery>
<Date>2007-09-03</Date>
<Time>06:12:06.000</Time>
</Delivery>
</DSchedule>
<DSchedule>
<Order>
<Date>2007-09-08</Date>
<Time>08:02:07.000</Time>
</Order>
<Delivery>
<Date>2007-09-09</Date>
<Time>06:12:08.000</Time>
</Delivery>
</DSchedule>
</StoreDelivery>
</Detail>
<Count>4</Count>
</DeliverySchedule>


I need to query the "Order" field or child where the field "Date"
inside it is equal for example "2007-09-02" and its parent "SiteNum" =
001507. Can I do that?

This will really help me a lot, thank you

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      09-11-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> <DeliverySchedule>
> <Header>
> <DistributorCode>MC</DistributorCode>
> <TransmissionDate>2007-01-02</TransmissionDate>
> <TransmissionTime>14:02:00.000</TransmissionTime>
> </Header>
> <Detail>
> <StoreDelivery>
> <SiteNum>001507</SiteNum>
> <DSchedule>
> <Order>
> <Date>2007-09-02</Date>
> <Time>08:02:01.000</Time>
> </Order>
> <Delivery>
> <Date>2007-09-03</Date>
> <Time>06:12:02.000</Time>
> </Delivery>
> </DSchedule>
> <DSchedule>
> <Order>
> <Date>2007-09-04</Date>
> <Time>08:02:03.000</Time>
> </Order>
> <Delivery>
> <Date>2007-09-05</Date>
> <Time>06:12:04.000</Time>
> </Delivery>
> </DSchedule>
> </StoreDelivery>
> <StoreDelivery>
> <SiteNum>001510</SiteNum>
> <DSchedule>
> <Order>
> <Date>2007-09-02</Date>
> <Time>08:02:05.000</Time>
> </Order>
> <Delivery>
> <Date>2007-09-03</Date>
> <Time>06:12:06.000</Time>
> </Delivery>
> </DSchedule>
> <DSchedule>
> <Order>
> <Date>2007-09-08</Date>
> <Time>08:02:07.000</Time>
> </Order>
> <Delivery>
> <Date>2007-09-09</Date>
> <Time>06:12:08.000</Time>
> </Delivery>
> </DSchedule>
> </StoreDelivery>
> </Detail>
> <Count>4</Count>
> </DeliverySchedule>
>
>
> I need to query the "Order" field or child where the field "Date"
> inside it is equal for example "2007-09-02" and its parent "SiteNum" =
> 001507. Can I do that?


The simple answer is "yes".

The longer answer is: Using which query language, and starting from
where in the document? Assuming XPath and a global search (which will
usually not be most efficient solution), one of many ways to express
this would be

//Order[Date='2007-09-02' and ../../Sitenum='001507']

See any good XPath tutorial to understand why this works, and what the
alternatives might be.

If you want to use another query language, see tutorials for that
language instead, of course.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      09-11-2007
Typo, of course -- SiteNum, not Sitenum. But you get the idea. Or, if
not, you need to do the recommended homework.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
kaissi@gmail.com
Guest
Posts: n/a
 
      09-11-2007
On Sep 10, 8:56 pm, Joe Kesselman <(E-Mail Removed)> wrote:
> Typo, of course -- SiteNum, not Sitenum. But you get the idea. Or, if
> not, you need to do the recommended homework.
>
> --
> () ASCII Ribbon Campaign | Joe Kesselman
> /\ Stamp out HTML e-mail! | System architexture and kinetic poetry


Thank you
It worked. Exactly what I wanted.

I owe you one.

 
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
Extracting the first child node of a parent node ofuuzo1@yahoo.no XML 2 03-17-2008 12:31 PM
select nodes with child node A and child node B gplott@yahoo.com XML 1 11-01-2006 09:27 PM
problem with child text node when constraining other child node types Bryan Ax XML 6 05-17-2006 09:08 PM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM



Advertisments