Android-XMLParser SAX-xml格式不正确
我必须从webservice获取的XML中检索数据 我使用SAX解析器,如下所示:Android-XMLParser SAX-xml格式不正确,android,xml,saxparser,Android,Xml,Saxparser,我必须从webservice获取的XML中检索数据 我使用SAX解析器,如下所示: URL url = new URL(webservice_url); SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); NewsHandler handler = new NewsHand
URL url = new URL(webservice_url);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
NewsHandler handler = new NewsHandler();
xr.setContentHandler(handler);
xr.parse(new InputSource(url.openStream()));
Xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<offerte_prodotti>
<num_pagine>154</num_pagine>
<product>
<id>6284</id>
<nome>Product description</nome>
<immagine>http://www.ownservercgi.com/images/cgi012548.jpg</immagine>
<euro>27.00</euro>
<scadenza>24/06/2014</scadenza>
<sconto>50%</sconto>
</product>
</offerte_prodotti>
我认为我是一个特殊的chars问题,但是其他活动中的其他方法使用我发布的代码工作得很好
这是一个XML文件问题吗?或者我可以通过代码来解决它吗?XML格式不正确-具体来说,开头的“offerte\u prodotti”元素没有关闭。XML应该是
154
6284
产品说明
http://www.ownservercgi.com/images/cgi012548.jpg
27
24/06/2014
50%
哦,对不起,我没有注意到。我编辑了问题,没有复制整个XML文件。多大的错误啊。。。
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 3292: not well-formed (invalid token)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515)
<?xml version="1.0" encoding="ISO-8859-1"?>
<offerte_prodotti>
<num_pagine>154</num_pagine>
<product>
<id>6284</id>
<nome>Product description</nome>
<immagine>http://www.ownservercgi.com/images/cgi012548.jpg</immagine>
<euro>27.00</euro>
<scadenza>24/06/2014</scadenza>
<sconto>50%</sconto>
</product>
</offerte_prodotti>