Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java- XML

 
Saiprasad Natarajan
Greenhorn
Posts: 12
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have an XML which is something like this:



All i want to do is get the queryValue by passing the queryName.
For ex: if I pass "CreateTask" to some function, the return value shoud be "Creating".

I am not sure if the DocumentBuilderFactory and other classes retrieve the value based on name.

Any pointers please?

TIA
 
Kshitij Chandrasen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai,
Yes the DOM parser doesn't do that. You will have to retrieve the "Query" tag elements as a NodeList and then iterate over them to perform search. Also, since the "queryname" and the "queryvalue" tags appear in pairs, you can actually directly retrieve these tags directly by using the getElementsByTabName(..) method and create a HashMap by mapping indices (As I said, since the items appear in pair, the index mapping would work fine).
Thanks
Kshitij
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic