wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to find highest marks in the xml file using SAXParser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to find highest marks in the xml file using SAXParser?" Watch "How to find highest marks in the xml file using SAXParser?" New topic
Author

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

Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51

xml file is <s> <name>s</name> <marks>10</marks> </s>............


Thanks in Advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
What is the output of the code, and what where you expecting it to do?


Ping & DNS - my free Android networking tools app
Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51
My output should be find highest marks in the Xyz.xml file using SAXParser.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
What does it do now? In other words, what's not working yet?
Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51
It displaying names and marks but my target is to find the highest marks from those list how to do it.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
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

Joined: Jul 18, 2008
Posts: 51
can you provide me any url or an example.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
An example of what? Which part didn't make sense to you?
Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51
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
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
HINT: If you are trying to find the "highest mark" in the numerical value sense, you will have to turn text into a number.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find highest marks in the xml file using SAXParser?