comp.text.xml
[Top] [All Lists]

Re: Looking for XPath solution with namespaces.

Subject: Re: Looking for XPath solution with namespaces.
From: Johannes Koch
Date: Fri, 25 Jul 2008 09:16:39 +0200
Newsgroups: comp.text.xml


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="                                queue.amazonaws.com/doc/">http://queue.amazonaws.com/doc/
2008-01-01">
         <CreateQueueResult>
            <QueueUrl>                                queue.amazonaws.com/foo">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 queue.amazonaws.com/doc/2008-01-01">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.)

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy