aspose file tools*
The moose likes XML and Related Technologies and the fly likes search elements of a node using entered value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "search elements of a node using entered value" Watch "search elements of a node using entered value" New topic
Author

search elements of a node using entered value

pourush rohila
Greenhorn

Joined: May 04, 2012
Posts: 11
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
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

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

Joined: May 04, 2012
Posts: 11
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: search elements of a node using entered value
 
Similar Threads
Easiest way to pass a username to a class
problems with getting text from field...
Changing Timeout
parse xml
Login Code Error