• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find highest marks in the xml file using SAXParser?

 
Rahul Noel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

xml file is <s> <name>s</name> <marks>10</marks> </s>............
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the output of the code, and what where you expecting it to do?
 
Rahul Noel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My output should be find highest marks in the Xyz.xml file using SAXParser.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it do now? In other words, what's not working yet?
 
Rahul Noel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It displaying names and marks but my target is to find the highest marks from those list how to do it.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to keep track of the highest value that gets reported in each call of the characters method. There may be an XPath expression you could use to select the highest value, but SAX is a low-level API where your code has to do a lot of the work instead.

Be aware that the "characters" method doesn't necessarily return the value "10" in one call - there could be two calls, one reporting "1" and then another one reporting "0". So you need to accumulate everything that gets reported between "marks" tags (possibly in a StringBuilder), and once the end tag is reached you can perform the comparison to the previous highest mark.
 
Rahul Noel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide me any url or an example.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of what? Which part didn't make sense to you?
 
Rahul Noel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am asking about how to find highest marks after parsing the xml file.can you tell me any example? If I dont know anything I will say I dont know but I dont ask a question again.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understand what you're trying to do, and I described one way to do that. If you didn't understand part of that approach, or have problems implementing it, then tell us in detail what you're struggling with. We won't write the code for you, but we'll help you write it yourself.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HINT: If you are trying to find the "highest mark" in the numerical value sense, you will have to turn text into a number.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic