Dear Team,
I am working on a requirement where in one of the java Application, as a POST request the application is receiving the XML content in the form of a String.
Here I have written the code to convert the String Data into an InputStream and passing the data into “document parser”. But the parser is not recognizing the inputstream content.
Example Code:
@RequestMapping(value = "/doc/example", method = {RequestMethod.GET, RequestMethod.POST})
public void generateEXAMPLEDOCUMENT(
@RequestParam(value = "inputData") String inputData,
HttpServletResponse response, HttpServletRequest request) {
InputSource inSource = new InputSource();
try {
//inputData is the XML content which is passed as String to this method
//Converting the String inputData into XML Stream
inSource.setCharacterStream(new StringReader(inputData));
} catch (Exception e) {
}
Document doc = new Document();
// Use DocumentBuilder from the javax.xml.parsers package and
// Document
// class from the org.w3c.dom package to read
// the XML data file and store it in memory.
javax.xml.parsers.DocumentBuilder db = DocumentBuilderFactory
.newInstance().newDocumentBuilder();
// Parse the XML data.
// org.w3c.dom.Document xmlData = db.parse(inSource);
…
…
…
Kindly help me in providing some inputs to proceed further.
Thanks and Regards
Pradeep