期待文件中的异常结束在解析XML数据的黑莓应用程序(Expecting End of File Exception in parsing xml data for Blackberry application)

461 IT屋

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

How do I fix it?

解决方案

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.

我得到解析器的例外是期待文件结束,而解析XML数据的黑莓应用程序吗?

如何解决呢?


解决方案

我遇到了同样的org.xml.sax.SAXException同时制定了子类org.xml.sax.helpers.DefaultHandler中的关于处理XML文件黑莓。

在我的情况的问题是,没有得到很好的形成我的示例XML文件。具体而言,有在XML文件中不只有一个根元素。我破碎的XML文件有几个根级标签,而SAX抱怨,它找到了第二个。这个文件看起来是这样的:

 &LT;?XML版本=1.0&GT?;
&所述;数 - 酮&​​下; /数&GT;
&LT;&号GT;二&LT; /数字&GT;
&LT;&号GT;三&LT; /数字&GT;

要修复它,我只是封装这些项目到一个名为计数一个根元素:

 &LT;?XML版本=1.0&GT?;
&LT;&计数GT;
&所述;数 - 酮&​​下; /数&GT;
&LT;&号GT;二&LT; /数字&GT;
&LT;&号GT;三&LT; /数字&GT;
&LT; /计数&GT;

您可以看到几个的XML规则维基百科在这里。

本文地址:IT屋 » 期待文件中的异常结束在解析XML数据的黑莓应用程序