File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading XML node attribute

 
uday kantt
Greenhorn
Posts: 26
Java MyEclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The following is the XML file
<Students>
<Student id=10>
<name>Steve</name>
<qualification status="failed">Computer Science</qualification>
</Student>
<Student id=9>
<name>John</name>
<qualification status="passed">Computer Graphics</qualification>
</Student>
<Student id=8>
<name>Sarah</name>
<qualification status="passed">Computer Science</qualification>
</Student>
</Students>


So given the above XML file. If the status ="passed" then that particular id of the Student should be fetched into the String variable. Is this possible. Do we have to travel reverse in the XML file. Is this possible. Please Help.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are parsing the XML to a DOM (Document Object Model) then you can use the methods in the standard Java library to "move" back from a child Node to a parent Node.

Study the org.w3c.dom.Node JavaDocs

bill
 
g tsuji
Ranch Hand
Posts: 649
3
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the xpath for the desired result(s).

ps: Your xml doc is not well-formed at the most basic level. Can you see it?!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic