The method DocumentBuilder#parse(String)
that you are using expects the URI of an XML source (e.g. file or HTTP URI), that holds the XML content, not the XML content itself.
If you really want to pass your XML content as a String
, consider passing an InputSource
wrapped around a StringReader
to DocumentBuilder#parse(InputSource)
:
documentBuilder.parse(new InputSource(new StringReader(source)));