Nov 10

DocumentBuilderFactory factory =
   DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(file);
// or if you need to specify an encoding explitily
// Document document = builder.parse(
//   new InputStreamReader(new FileInputStream(file), encoding)); 

written by objects \\ tags: , , ,

One Ping to “How do I create a DOM Document from an XML file?”

  1. How to add indentation to an xml file? | web development helpdesk Says:

    [...] how-do-i-create-a-dom-document-from-an-xml-file [...]


Leave a Reply