I have been trying to convert an xml string into a document so I can later add a node, I have found the same solution in 5 different places however my IDE is giving me an error. The error reads as "the method parse(inputstream)in type DocumentBuilder is not applicable for the arguments(inputSource)."
I have tried the exact code multiple times including choosing the right method output, but I keep getting the same error.
private static Document converStringToDocument(String xml) {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document document = docBuilder.parse(new InputSource(new StringReader(xml)));
return document;
}
I want this to return a document so I can add a node.