Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get Element value using another element

 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I found one here

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

Kathir
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic