WARN/ExpatReader(718): DTD handlers aren't supported.

Put your problem here if it does not fit any of the other categories.

WARN/ExpatReader(718): DTD handlers aren't supported.

Postby exsharmilau » Thu Mar 17, 2011 6:49 am

hi

I am using SAXParser for parsing the xml data received from server.
I have created the abstract class XmlParser extends DefaultHandler with abstract methods characters(),startelement(),endelement().I have encountered this issue(WARN/ExpatReader(718): DTD handlers aren't supported.)My PArsing stops in the middle.I have referred some answers suggested to follow the below code
My code
Code: Select all
public abstract class XmlParser extends DefaultHandler {

    public XmlParser(final String xmlData) {
        parseDocument(xmlData);
    }

    @Override
   public abstract void characters(char[] ch, int start, int length)
        throws SAXException;

    @Override
   public abstract void endElement(String uri, String localName, String qName)
        throws SAXException;

    private void parseDocument(final String xmlData) {
        SAXParserFactory spf = SAXParserFactory.newInstance();

        try {
            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(xmlData.getBytes("UTF-8"));<----I think i have to change here
            sp.parse(is, this);
        } catch (SAXException ex) {
            ex.printStackTrace();
        } catch (ParserConfigurationException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
   
    @Override
   public abstract void startElement(String uri, String localName,
        String qName, Attributes attributes) throws SAXException;   
}

Code: Select all
Referred answer
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
xmlReader.setContentHandler(//YourHandler extends DefaultHandler);
xmlReader.parse(new InputSource(//BufferedReader));


problem for me
i have an abstract class that extends defaulthandler.
I cant create a object for it to pass in setContentHandler() method.
I should keep this XmlParser as abstract since i have to override for each module parser
So suggest me a solution to overcome this issue
exsharmilau
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 17, 2011 6:33 am

Top

Re: WARN/ExpatReader(718): DTD handlers aren't supported.

Postby raj_J2ME » Thu Mar 17, 2011 10:07 am

Please don't start the multiple threads with the same issue, your this thread is already here,
http://www.anddev.org/posting.php?mode=reply&f=5&t=51792
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests