Looking for XPath solution with namespaces.

J

Jason8

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>
 
J

Johannes Koch

Jason8 said:
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.
 
J

Jason8

Jason8 schrieb:







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.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top