It's not a secret anymore!
The moose likes XML and Related Technologies and the fly likes Sax parsing using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Sax parsing using java" Watch "Sax parsing using java" New topic

Sax parsing using java

Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 95
Hi I am using sax parser to parse an xml file in java.Here is the xml file

I parsed the code and i could get all its element name and its attribute values.But I am interested in getting the details of the Mol and Name tags.Here is the code that I am using it do it.

But what i actually want is when the tag name is mol i want its type alone.
then if the type is "compound" then i want only the attributes long_name="EzGeny" and value="2241" and dont want the rest.
How do i got about doing this,any suggestions please

SCJP 6.0
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
if(strQName=="Mol" || strQName=="Name" )

In Java, string equality isn't checked with the "==" operator, it's checked with the "equals" method.
I agree. Here's the link:
subject: Sax parsing using java
It's not a secret anymore!