• Post Reply Bookmark Topic Watch Topic
  • New Topic

search elements of a node using entered value  RSS feed

 
pourush rohila
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to create a prog to search a element from a node and all its siblings e.g.
i am having this xml file



i want to search value "jdbc:odbc:Mydata" and if user enter this value than i want to access all other elements form this node.
like
name, username, password

thnks in advance
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you're asking for suggestions about how to do it, I would suggest first parsing the document into a DOM, then using an XPath expression which selects the <Database> elements which are parents of the <name> elements which contain the chosen text. Then access those elements' children as required.
 
pourush rohila
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks paul i read the xpath tutorial on w3 and use xpath and by using preceding sibling i get the values but i want specific node but it gives all siblings from all node not from selected node can you give me any example. because there is no method or idea to get node using value
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!