Selecting a node with child and parent condition.

Discussion in 'XML' started by okaissi79@gmail.com, Sep 11, 2007.

  1. Guest

    <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
     
    , Sep 11, 2007
    #1
    1. Advertising

  2. 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
     
    Joe Kesselman, Sep 11, 2007
    #2
    1. Advertising

  3. 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
     
    Joe Kesselman, Sep 11, 2007
    #3
  4. Guest

    On Sep 10, 8:56 pm, Joe Kesselman <> 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.
     
    , Sep 11, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,646
  2. Bryan Ax
    Replies:
    6
    Views:
    566
    Peter Flynn
    May 17, 2006
  3. Replies:
    1
    Views:
    1,228
    Joe Kesselman
    Nov 1, 2006
  4. Replies:
    2
    Views:
    847
    Martin Honnen
    Mar 17, 2008
  5. Noel Dolan
    Replies:
    0
    Views:
    273
    Noel Dolan
    Jul 18, 2004
Loading...

Share This Page