Looking for XPath solution with namespaces.

Discussion in 'XML' started by Jason8, Jul 25, 2008.

  1. Jason8

    Jason8 Guest

    Hi:

    I'm looking to get the values of QueueUrl, and RequestId from below
    using XPath but I can't get past soapenv:Body without using wild
    cards. For example these move down the tree:

    /soapenv:Envelope/soapenv:Body/*
    /soapenv:Envelope/soapenv:Body/*/*

    But this gives me nothing:
    /soapenv:Envelope/soapenv:Body/CreateQueueResponse/*

    I have a feeling it has to do with the xmlns in the
    CreateQueueResponse but I can't find anything that documents how to
    deal with it in XPath.

    <?xml version="1.0"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
    envelope/">
    <soapenv:Body>
    <CreateQueueResponse xmlns="http://queue.amazonaws.com/doc/
    2008-01-01">
    <CreateQueueResult>
    <QueueUrl>http://queue.amazonaws.com/foo</QueueUrl>
    </CreateQueueResult>
    <ResponseMetadata>
    <RequestId>935082d0-a431-4da0-a5f1</RequestId>
    </ResponseMetadata></CreateQueueResponse>
    </soapenv:Body>
    </soapenv:Envelope>
     
    Jason8, Jul 25, 2008
    #1
    1. Advertising

  2. Jason8 schrieb:
    > Hi:
    >
    > I'm looking to get the values of QueueUrl, and RequestId from below
    > using XPath but I can't get past soapenv:Body without using wild
    > cards. For example these move down the tree:
    >
    > /soapenv:Envelope/soapenv:Body/*
    > /soapenv:Envelope/soapenv:Body/*/*
    >
    > But this gives me nothing:
    > /soapenv:Envelope/soapenv:Body/CreateQueueResponse/*
    >
    > I have a feeling it has to do with the xmlns in the
    > CreateQueueResponse but I can't find anything that documents how to
    > deal with it in XPath.
    >
    > <?xml version="1.0"?>
    > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
    > envelope/">
    > <soapenv:Body>
    > <CreateQueueResponse xmlns="http://queue.amazonaws.com/doc/
    > 2008-01-01">
    > <CreateQueueResult>
    > <QueueUrl>http://queue.amazonaws.com/foo</QueueUrl>
    > </CreateQueueResult>
    > <ResponseMetadata>
    > <RequestId>935082d0-a431-4da0-a5f1</RequestId>
    > </ResponseMetadata></CreateQueueResponse>
    > </soapenv:Body>
    > </soapenv:Envelope>


    The CreateQueueResponse element and its descendant elements are in the
    http://queue.amazonaws.com/doc/2008-01-01 namespace. So pick a namespace
    prefix for this namespace, register it in your XPath application and use
    it in the XPath.

    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Jul 25, 2008
    #2
    1. Advertising

  3. Jason8

    Jason8 Guest

    On Jul 25, 12:16 am, Johannes Koch <> wrote:
    > Jason8 schrieb:
    >
    >
    >
    > > Hi:

    >
    > > I'm looking to get the values of QueueUrl, and RequestId from below
    > > using XPath but I can't get past soapenv:Body without using wild
    > > cards. For example these move down the tree:

    >
    > > /soapenv:Envelope/soapenv:Body/*
    > > /soapenv:Envelope/soapenv:Body/*/*

    >
    > > But this gives me nothing:
    > > /soapenv:Envelope/soapenv:Body/CreateQueueResponse/*

    >
    > > I have a feeling it has to do with the xmlns in the
    > > CreateQueueResponse but I can't find anything that documents how to
    > > deal with it in XPath.

    >
    > > <?xml version="1.0"?>
    > > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
    > > envelope/">
    > >   <soapenv:Body>
    > >       <CreateQueueResponse xmlns="http://queue.amazonaws.com/doc/
    > > 2008-01-01">
    > >          <CreateQueueResult>
    > >             <QueueUrl>http://queue.amazonaws.com/foo</QueueUrl>
    > >          </CreateQueueResult>
    > >          <ResponseMetadata>
    > >            <RequestId>935082d0-a431-4da0-a5f1</RequestId>
    > >          </ResponseMetadata></CreateQueueResponse>
    > >    </soapenv:Body>
    > > </soapenv:Envelope>

    >
    > The CreateQueueResponse element and its descendant elements are in thehttp://queue.amazonaws.com/doc/2008-01-01namespace. So pick a namespace
    > prefix for this namespace, register it in your XPath application and use
    > it in the XPath.
    >
    > --
    > Johannes Koch
    > In te domine speravi; non confundar in aeternum.
    >                              (Te Deum, 4th cent.)


    Thanks for the reply. I thought this was possible directly in XPath
    with something like "{http://queue.amazonaws.com/doc/
    2008-01-01}CreateQueueResponse"? Perhaps that is dependent on the
    parser though.
     
    Jason8, Jul 26, 2008
    #3
    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. Jim
    Replies:
    2
    Views:
    451
    Richard Tobin
    Jan 29, 2004
  2. kj
    Replies:
    3
    Views:
    22,603
    sandhya
    Mar 27, 2010
  3. Stefan Franke

    XPath and namespaces...

    Stefan Franke, Jan 2, 2005, in forum: XML
    Replies:
    6
    Views:
    1,082
    Martin Honnen
    Jan 3, 2005
  4. Replies:
    1
    Views:
    466
    Romin
    Apr 20, 2005
  5. Omar
    Replies:
    4
    Views:
    18,145
    Patrick TJ McPhee
    Jun 21, 2005
Loading...

Share This Page