DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Java DOM : Creating An XML Document From XML File

05.14.2007
| 18416 views |
  • submit to reddit
        // description of your code here

    try
    {
      //
      // Create the XML Document
      //

      DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
      Document doc = docBuilder.parse(filePath);

      // ...

    }
    catch (Exception e)
    {
      // ...
    }