Looking for XPath solution with namespaces.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason8

    Looking for XPath solution with namespaces.

    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:Envelop e/soapenv:Body/*
    /soapenv:Envelop e/soapenv:Body/*/*

    But this gives me nothing:
    /soapenv:Envelop e/soapenv:Body/CreateQueueResp onse/*

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

    <?xml version="1.0"?>
    <soapenv:Envelo pe xmlns:soapenv=" http://schemas.xmlsoap .org/soap/
    envelope/">
    <soapenv:Body >
    <CreateQueueRes ponse xmlns="http://queue.amazonaws .com/doc/
    2008-01-01">
    <CreateQueueRes ult>
    <QueueUrl>htt p://queue.amazonaws .com/foo</QueueUrl>
    </CreateQueueResu lt>
    <ResponseMetada ta>
    <RequestId>9350 82d0-a431-4da0-a5f1</RequestId>
    </ResponseMetadat a></CreateQueueResp onse>
    </soapenv:Body>
    </soapenv:Envelop e>

  • Johannes Koch

    #2
    Re: Looking for XPath solution with namespaces.

    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:Envelop e/soapenv:Body/*
    /soapenv:Envelop e/soapenv:Body/*/*
    >
    But this gives me nothing:
    /soapenv:Envelop e/soapenv:Body/CreateQueueResp onse/*
    >
    I have a feeling it has to do with the xmlns in the
    CreateQueueResp onse but I can't find anything that documents how to
    deal with it in XPath.
    >
    <?xml version="1.0"?>
    <soapenv:Envelo pe xmlns:soapenv=" http://schemas.xmlsoap .org/soap/
    envelope/">
    <soapenv:Body >
    <CreateQueueRes ponse xmlns="http://queue.amazonaws .com/doc/
    2008-01-01">
    <CreateQueueRes ult>
    <QueueUrl>htt p://queue.amazonaws .com/foo</QueueUrl>
    </CreateQueueResu lt>
    <ResponseMetada ta>
    <RequestId>9350 82d0-a431-4da0-a5f1</RequestId>
    </ResponseMetadat a></CreateQueueResp onse>
    </soapenv:Body>
    </soapenv:Envelop e>
    The CreateQueueResp onse 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.)

    Comment

    • Jason8

      #3
      Re: Looking for XPath solution with namespaces.

      On Jul 25, 12:16 am, Johannes Koch <k...@w3develop ment.dewrote:
      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:Envelop e/soapenv:Body/*
      /soapenv:Envelop e/soapenv:Body/*/*
      >
      But this gives me nothing:
      /soapenv:Envelop e/soapenv:Body/CreateQueueResp onse/*
      >
      I have a feeling it has to do with the xmlns in the
      CreateQueueResp onse but I can't find anything that documents how to
      deal with it in XPath.
      >
      <?xml version="1.0"?>
      <soapenv:Envelo pe xmlns:soapenv=" http://schemas.xmlsoap .org/soap/
      envelope/">
        <soapenv:Body >
            <CreateQueueRes ponse xmlns="http://queue.amazonaws .com/doc/
      2008-01-01">
               <CreateQueueRes ult>
                  <QueueUrl>htt p://queue.amazonaws .com/foo</QueueUrl>
               </CreateQueueResu lt>
               <ResponseMetada ta>
                 <RequestId>9350 82d0-a431-4da0-a5f1</RequestId>
               </ResponseMetadat a></CreateQueueResp onse>
         </soapenv:Body>
      </soapenv:Envelop e>
      >
      The CreateQueueResp onse 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}CreateQueueR esponse"? Perhaps that is dependent on the
      parser though.

      Comment

      Working...