• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SAX parser: handling empty tags

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How do you handle empty tags( <abc></abc> or <abc/> ). Ideally, I should get a "" as the parsed value. But I'm getting tabs and new lines. Does anyone know the answer as to why this is happening?
Thanks and regards,
D. Kiran Kumar.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kiran, would you mind separating your display name into two (or three) pieces? That's what our naming policy requires. You can change your display name here.
Thanks.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding your problem, could you post the SAX handler you've written? It might help solving the problem.
 
D Kiran Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
This is the characters() method that I've overridden.
My SAXHandler extends DefaultHandler and I'm using
org.apache.xerces.parsers.SAXParser
public void characters( char[] ch, int start, int length )
{
_sbValue = new StringBuffer();
_sbValue.append( ch, start, length );
}//End of method
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your characters() is getting tabs and new-lines then I bet there are tabs and new-lines in your actual document. How is the document being generated? How are you examining it?
Bill
 
D Kiran Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is right.
The xml doc I'm parsing is indented with tabs and every tag starts from a new line. The xml is not dynamically generated either. I didn't get what you meant by "examining".
 
reply
    Bookmark Topic Watch Topic
  • New Topic