09-08-2008 05:48 AM
Hi,
I am parsing the the xml which i have received as response inputstream after http connection.
xml format is as follows,
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : LoginAuthentication.xml
Created on : 2 September, 2008, 11:07 AM
Author : admin
Description:
Purpose of the document follows.
-->
<OpenPWS>
<status> true </status>
</OpenPWS>
and the source code peace to parse is as follows,
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
try{
document = builder.parse(is);//is contains the response inputstream
}catch(Exception e){
notifyUser("exception in builder.parse"+e.getMessage());
}
but i am getting the "exception in builder.parse" exception.
can any one tell me whats the problem here?.
09-08-2008 11:06 AM
09-09-2008 12:40 AM
09-09-2008 01:19 AM
try this
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inputStream = getClass().getResourceAsStream( _xmlFileName ); Document document = builder.parse( inputStream); Element rootElement = document.getDocumentElement();
09-09-2008 02:33 AM
The inputstream is coming from server as a inputstreamdata. so i want to parse it dynamically.
the above is working fine with .xml file.
09-09-2008 03:16 AM
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); StringBuffer stringBuffer = new StringBuffer("any string like...."); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(stringBuffer.toString().getBy
tes("UTF-8")); Document document = builder.parse( byteArrayInputStream );
09-09-2008 07:10 AM
Thanks for your reply.
i think the problem with xml whatever they(server) are sending .