11-Jun-03 (Created: 11-Jun-03) | More in 'CS-xml'

Sample code to open an xml file

Sample code to open an xml file

   private void processXMLConfigFile(String filename)
   {
      try
      {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document doc = builder.parse(filename);

      }
      catch(ParserConfigurationException x)
      {

AppObjects.log("Error:XMLConfigFileProcessor:processxXMLConfigFile",x);
      }
      catch(IOException x)
      {

AppObjects.log("Error:XMLConfigFileProcessor:processxXMLConfigFile",x);
      }
      catch(SAXException x)
      {
	// why this exception

AppObjects.log("Error:XMLConfigFileProcessor:processxXMLConfigFile",x);
      }
      finally
      {
      }

   }

Import packages

import javax.xml.parsers.*;
import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException; // why?