• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with (my) XPath

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using javax.xml.xpath.XPath to find occurrences of elements (in any level) namely 'Password' in a SOAP request, and replace them with xxxx to mask them, just before logging SOAP message to console.

Strangely following expression,

//Password

doesn't return any nodes. However

/.//Password returns the node.

Here is the code:



Here is the XML payload:



I appreciate any help.
thanks
IB
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't be looking for a "Password" element; you should be looking for a "Password" element in the "http://test.ibswings.com" namespace. You would need to provide a namespace context to your XPath object to do that.
 
Ishwara Varnasi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul for reply,

name space may not be an issue here - I am setting setNamespaceAware(false) on the DocumentBuilderFactory while parsing document.

As I said above, the following

returns nodes (and I can mask the password). However

doesn't return the node.

Here is the code I parse xml string to Document object.



thanks
IB
 
reply
    Bookmark Topic Watch Topic
  • New Topic