Sunday, November 7, 2010

Convert an InputStream to XML

For that we can use DocumentBuilder class in java. By using the method parse(InputStream) ;A new DOM Document object will return.

InputStream input;

DocumentBuilderFactory factory
= DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document dc= parser.parse(input);

In the above code segment,by using the created Document object,the corresponding XML file for the inputStream can be accessed.


No comments:

Post a Comment