my dog learned polymorphism
The moose likes Other JSE/JEE APIs and the fly likes SAXParser Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "SAXParser Problem" Watch "SAXParser Problem" New topic

SAXParser Problem

Jayesh Netravali

Joined: May 07, 2003
Posts: 12
I have an odd problem. I am using a SAX parser to parse an XML file which has a root and a number of repeating elements in the root. For eg. It is like representing a Database table in the XML format. The format is
<column1>value1</column1> <column2>value2</column2>...

I parse this XML using the javax.xml.parsers.SAXParser. My parser class extends the DefaultHandler. I have to display this info in a JTable. Hence I make a Vector of Vectors by reading the String by overriding the characters() method of the DefaultHandler

The problem is after some 90-95 <row> tags the characters() method returns me the value of the text content for a tag in two parts. i.e for eg for the 91st row if the tag is <column1>This is-a test message</column1> it returns me 'This is' and '-a test message' as two Strings. Thus one String is stored in my vector in two parts, which screws up my table display.

If I delete one row from the xml file then the problem shifts to the next row in the file. I dont know if it some problem with the capacity of a vector?

Any pointers to the solun of the above problem would be helpful.

Thanks in advance,
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

That is just the way SAX works. You are never guarenteed that all the text will be contained in one call to the handler. Your handler must be able to account for this.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: SAXParser Problem
It's not a secret anymore!