Parse XML special characters?

前端 未结 5 940
时光取名叫无心
时光取名叫无心 2021-01-23 21:36

From the last 2 days I am searching that how to parse XML with special chars like !@#$%^&*()\':;\", but I am not getting anything sufficient that how to implement it.. Can a

5条回答
  •  遇见更好的自我
    2021-01-23 22:00

     public void XmlParsing(String questions_xml)
    {
        try {
    
            /** Handling XML */
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
    
            /** Create handler to handle XML Tags ( extends DefaultHandler ) */
            MyXmlHandler myXMLHandler = new MyXmlHandler();
            xr.setContentHandler(myXMLHandler);
    
            xr.parse( new InputSource(new StringReader(questions_xml)));
    
    
            } catch (Exception e) {
                String err = (e.getMessage()==null)?"XMLParsing exception":e.getMessage();
                Log.e("XMLParsing Exception",err); 
            }
    
    
    }
    now when I am trying to parse & then my app crashes?
    

提交回复
热议问题