How to solve docbuiler saxexception: unexpected end of document?
- by user211992
I have a service that gives some car information in an xml format.
<?xml version="1.0" encoding='UTF-8'?>
<car>
<id>5</id>
<name>qwer</name>
</car>
<car>
<id>6</id>
<name>qwert</name>
</car>
Now the problem that I'm having is that my
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(xml);
Sometimes throws a SAXException (sometimes it works just fine, but when I reboot the server (still in development) I sometimes keep getting it) with as cause SAXException: unexpected end of document.
But when I place a bufferreader there to see what it's receiving and I copy the value into an xml document and I open it in firefox/ie it looks just fine.