Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Seek XPath Expression

Reply
Thread Tools

Seek XPath Expression

 
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      06-12-2008
This may be so easy no one responds.

What is the XPath expression that fetches the value PPV - the
PersistentTicket?

The namespace thing is throwing me off.

Thanks.

<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/
XMLSchema"><soap:Header><CompanyAuthHeader xmlns="http://
webservices.monster.com/MonsterPortal"><PersistentTicket>PPV</
PersistentTicket>
</CompanyAuthHeader>
</soap:Header>
<soap:Body>
<AuthenticateByCompanyAccessTicketResponse xmlns="http://ws.com/VX">
<AuthenticateByCompanyAccessTicketResult>true</
AuthenticateByCompanyAccessTicketResult>
</AuthenticateByCompanyAccessTicketResponse>
</soap:Body>
</soap:Envelope>

 
Reply With Quote
 
 
 
 
pr
Guest
Posts: n/a
 
      06-12-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> This may be so easy no one responds.
>
> What is the XPath expression that fetches the value PPV - the
> PersistentTicket?
>
> The namespace thing is throwing me off.
>
> Thanks.
>
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xmlnssd="http://www.w3.org/2001/
> XMLSchema"><soap:Header><CompanyAuthHeader xmlns="http://
> webservices.monster.com/MonsterPortal"><PersistentTicket>PPV</
> PersistentTicket>
> </CompanyAuthHeader>
> </soap:Header>
> <soap:Body>
> <AuthenticateByCompanyAccessTicketResponse xmlns="http://ws.com/VX">
> <AuthenticateByCompanyAccessTicketResult>true</
> AuthenticateByCompanyAccessTicketResult>
> </AuthenticateByCompanyAccessTicketResponse>
> </soap:Body>
> </soap:Envelope>
>


The most efficient would be:

/soap:Envelope/soap:Header/
monster:CompanyAuthHeader/monsterersistentTicket/text()

where you have declared (by whatever means appropriate in the tool
you're using)

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:monster="http://webservices.monster.com/MonsterPortal"


You could also do:

//monsterersistentTicket/text()

or (without declaring the namespaces):

//*[local-name() = 'PersistentTicket' and namespace::node()[. =
'http://webservices.monster.com/MonsterPortal']]/text()
 
Reply With Quote
 
 
 
 
pr
Guest
Posts: n/a
 
      06-12-2008
pr wrote:
> //*[local-name() = 'PersistentTicket' and namespace::node()[. =
> 'http://webservices.monster.com/MonsterPortal']]/text()


Sorry. Should be:

//*[local-name() = 'PersistentTicket' and namespace-uri() =
'http://webservices.monster.com/MonsterPortal']/text()
 
Reply With Quote
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      06-13-2008
On Jun 12, 4:27*am, pr <(E-Mail Removed)> wrote:
> pr wrote:
> > * //*[local-name() = 'PersistentTicket' and namespace::node()[. =
> > * * 'http://webservices.monster.com/MonsterPortal']]/text()

>
> Sorry. Should be:
>
> * *//*[local-name() = 'PersistentTicket' and namespace-uri() =
> * * *'http://webservices.monster.com/MonsterPortal']/text()


This worked perfectly. Thanks Pr.

I'm using Java (org.jdom.xpath.XPath) which has the following method:

addNamespace(java.lang.String prefix, java.lang.String uri)
which adds a namespace definition (prefix and URI) to the list of
namespaces known of this XPath expression.

My this case, what are the values of prefix and uri?

Thanks.


 
Reply With Quote
 
pr
Guest
Posts: n/a
 
      06-13-2008
(E-Mail Removed) wrote:
> I'm using Java (org.jdom.xpath.XPath) which has the following method:
>
> addNamespace(java.lang.String prefix, java.lang.String uri)
> which adds a namespace definition (prefix and URI) to the list of
> namespaces known of this XPath expression.
>
> My this case, what are the values of prefix and uri?


The prefix is up to you, provided you don't repeat a prefix already used
in your document (e.g. 'soap'), start the prefix with a letter or
underscore, and confine yourself to the characters

A-Z a-z 0-9 _ - .

(or consult <URL: http://www.w3.org/TR/xml-names> for the full range of
permissible characters, software permitting).

Without knowing Java in any detail, I presume

addNamespace("monster",
"http://webservices.monster.com/MonsterPortal")

is appropriate if you want to use

monsterersistentTicket

in your XPath, and

addNamespace("m", "http://webservices.monster.com/MonsterPortal")

if you want to use

mersistentTicket

The significant thing about the namespace is its URI - you could add the
namespace twice and use the prefixes interchangeably, although that
might be unnecessarily confusing
 
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
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net Building Controls 0 07-29-2008 01:37 AM



Advertisments