I am trying to use the parse
method that takes an InputSource
to parse a DocumentBuilder
instance.
The error is:
The method parse(InputStream) in the type DocumentBuilder is not applicable for the arguments (InputSource)
This is the code:
public static Document loadXMLFromString(String xml) throws Exception {
DocumentBuilder factory = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = factory.parse(new InputSource(new StringReader(xml)));
}
It is asking me to change to InputStream
.. Checked the documentation and one of the parse methods in DocumentBuilder
takes an InputSource
. What is the problem?