Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes get Element value using another element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "get Element value using another element" Watch "get Element value using another element" New topic
Author

get Element value using another element

Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi there,

I have the XML data like

<databases>
<database>
<user-name>db-user1</user-name>
<password>db-passwd1</password>
</database>

<database>
<user-name>db-user2</user-name>
<password>db-passwd2</password>
</database>
</databases>

I have to get the string "db-passwd2" using "db-user2"
I do not want to write the code for iterate all the element and get this.
Can anyone tell is there any builtin function availbale for this ?

Thanks
Kathiresan

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The "built-in" function you are thinking of is for you to write and execute an XPath expression which finds the node you want.
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi,

I am not familiar with XPath expression.
Can you simply tell how to get started or links ?

Thank you
Kathir
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115

Hi,

I found one here

http://www.ibm.com/developerworks/library/x-javaxpathapi.html

Kathir
 
wood burning stoves
 
subject: get Element value using another element
 
Similar Threads
403 access denied error
Resin DB-pooling + authentication. HELP!
Tomcat Connection Pooling Help required
Sorting on a property of an inner object (object within an object)
JBOSS FORM based auth and 403