xml parser for filterig empty tags

J

Jander

I'm parsing an xml file with SAXParser ,i extended DefaultHandler for
parsing it ,so my bean overrides several methods as

startDocument()
endDocument()
startElement()

....

my tarjet is filtering empty tags in my xml files ,but with this method
i can't do that with this methods .

What other aproach migth use ?
Any ideas ?

Thanks
 
S

Sudsy

Jander said:
I'm parsing an xml file with SAXParser ,i extended DefaultHandler for
parsing it ,so my bean overrides several methods as

startDocument()
endDocument()
startElement()

...

my tarjet is filtering empty tags in my xml files ,but with this method
i can't do that with this methods .

Sure you can: you just have to think the problem through. If the methods
are called in the following order then there is content:
startElement()
characters()
endElement()
However, this order would suggest an empty element:
startElement()
endElement()
So perhaps you set a boolean in the startElement method and clear it in
the characters method. When you get to the endElement method you check
the variable: if set then element was empty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top