views:

456

answers:

2

Hi All,

I am getting parser exception as "Expecting End of File" while parsing xml data for Blackberry application?

How do I fix it?

A: 

I Have the same probem. Can anyone help me??

Patrick
+1  A: 

I encountered the the same org.xml.sax.SAXException while developing a child class of org.xml.sax.helpers.DefaultHandler for processing an XML file on Blackberry.

The issue in my case was that my sample XML file was not well-formed. Specifically, there was not only one root element in the XML file. My broken XML file had several root-level tags, and SAX was complaining that it found a second one. The file looked something like this:

<?xml version="1.0"?>
<number>one</number>
<number>two</number>
<number>three</number>

To fix it, I just encapsulated those items into one root element named "counting":

<?xml version="1.0"?>
<counting>
<number>one</number>
<number>two</number>
<number>three</number>
</counting>

You can see a few of the XML rules on Wikipedia here.

John M. P. Knox
I hit exactly this problem, thanks for your very useful solution!
Dan J
Cool. Glad to help!
John M. P. Knox