Example usage for javax.xml.transform Source toString

List of usage examples for javax.xml.transform Source toString

Introduction

In this page you can find the example usage for javax.xml.transform Source toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:jlib.xml.XMLUtil.java

public static Document LoadXML(Source file) {
    try {//from www  . j av a 2s.c  o m
        DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        Result res = new DOMResult(doc);
        TransformerFactory tr = TransformerFactory.newInstance();
        Transformer xformer = tr.newTransformer();
        xformer.transform(file, res);

        return doc;
    } catch (Exception e) {
        String csError = e.toString();
        Log.logImportant(csError);
        Log.logImportant("ERROR while loading XML " + file.toString());
    }
    return null;
}