Android XML parser 3G issue: result string are splitted and duplicated

62 Views Asked by At

I have to retrieve datas from a XML got from webservice.

I use SAX parser, like follow:

                URL url = new URL(this.pUrl);
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
                ProductsHandler handler = new ProductsHandler();
                xr.setContentHandler(handler);
                InputSource is = new InputSource(url.openStream());
                is.setEncoding("ISO-8859-1");
                xr.parse(is);

XML item:

<product>
    <id_product>4548</id_product>
    <name>Special snack 30gr chocolate</name>
    <price>15,00</price>
</product>

Handler snippet:

..
else if(localName.equals("name")){
            this.in_nome=true;
        }
..
else if(localName.equals("name")){
            this.in_nome=false;
        }
..
else if(this.in_name){
            xmlparsing.setNames(new String(ch , start , length));
        }

When i use WiFi connection, it works well.

If i use 3G connection, some item are splitted and duplicated.

e.g.

WiFi behaviour:

Product name: Special snack 30gr chocolate

3G behaviour:

Product Name: Special sna;
Product Name: Special snack 30gr chocolate;

This behaviour cause an issue in the products list (product id associated to wrong name).

How can i solve it?

0

There are 0 best solutions below