Code example for CharArrayReader

0
			DocumentBuilderFactory factory = DocumentBuilderFactory
					.newInstance();
			// Use document builder factory 
			DocumentBuilder builder = factory.newDocumentBuilder();
			// Parse the document 
			Reader reader = new CharArrayReader(xml.toCharArray());
			Document doc = builder.parse(new org.xml.sax.InputSource(reader));
			return doc;
		} catch (Exception e) {
			logger.error("An error occured while creating document ** ", e);
			throw new Exception(e.getMessage());
		} 
	} 
}