I need help. In my String filedata variable, I saved an XML document. Now I want to convert this variable to a DOMSource type and use this code:
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = db.parse( new InputSource( new StringReader( filedata ) ) ); DOMSource source = new DOMSource(doc);
and converted using javax.xml.transform.Transformer:
Transformer transformer = XMLTransformerFactory.getTransformer(messageType); StreamResult res = new StreamResult(flatXML); transformer.transform(source, res);
But my flatXML is empty after conversion. I checked my doc variable and it contains my XML document and everything parses correctly. If I change my source code to the real path, everything will be fine and works fine:
Source source = new StreamSource("c:\\temp\\log\\SMKFFcompleteProductionPlan.xml");
I think my problem is in this line of code:
DOMSource source = new DOMSource(doc);
but I donβt know how to solve this problem.
source share