XML的一个例子

   public static void writeXml(Document doc, File file)
    {
        try
        {
            Transformer former = TransformerFactory.newInstance().newTransformer();
            FileOutputStream fOutputStream = new FileOutputStream(file);
            former.transform(new DOMSource(doc), new StreamResult(fOutputStream));
            fOutputStream.close();
        }
        catch (TransformerException tE)
        {
            LogService.getInstance().runLog(LOG_LEVEL.LEVEL_ERROR, false, tE);
        }
        catch (FileNotFoundException fnfE)
        {
            LogService.getInstance().runLog(LOG_LEVEL.LEVEL_ERROR, false, fnfE);
        }
        catch (IOException ioE)
        {
            LogService.getInstance().runLog(LOG_LEVEL.LEVEL_ERROR, false, ioE);
        }
    }

你可能感兴趣的:(xml)