Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Looking for XPath solution with namespaces.

Reply
Thread Tools

Looking for XPath solution with namespaces.

 
 
Jason8
Guest
Posts: n/a
 
      07-25-2008
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>

 
Reply With Quote
 
 
 
 
Johannes Koch
Guest
Posts: n/a
 
      07-25-2008
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.)
 
Reply With Quote
 
 
 
 
Jason8
Guest
Posts: n/a
 
      07-26-2008
On Jul 25, 12:16*am, Johannes Koch <k...@w3development.de> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57