Fix XXE vulnerability in XML.getDocument()

and provide safe newDocumentBuilder() method for other uses