问题
I am getting parser exception as "Expecting End of File" while parsing xml data for Blackberry application?
How do I fix it?
回答1:
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.
来源:https://stackoverflow.com/questions/1755569/expecting-end-of-file-exception-in-parsing-xml-data-for-blackberry-application