parsing huge length string using sax parser in android

后端 未结 3 1203
面向向阳花
面向向阳花 2021-01-24 10:51

I parsing the xml using sax parser in android. My xml structure is as given below

   
        
              

        
3条回答
  •  故里飘歌
    2021-01-24 11:00

    In sax parser, characters() method parses only maximum of 1024 characters each time. So we need to append the strings until all the characters are parsed.

    I changed the above code as follows

    public void characters(char[] ch, int start, int length)
            throws SAXException
    {
    
    
        Log.d("prabhu","Customer image length in parser......"+length);
        if (currentElement ) {
    
            tempValue = new String(ch,start, length);
    
            if(tempValue.equals(null))
                tempValue = "";
    
    
    
        }
            tempValue = tempValue+new String(ch,start, length);
     }
    

提交回复
热议问题