Java XML Node Transform write(final Node node, final Result result)

Here you can find the source of write(final Node node, final Result result)

Description

write

License

Open Source License

Declaration

private static void write(final Node node, final Result result) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.j  av  a 2  s. c  om*/
This file is part of Cyclos (www.cyclos.org).
A project of the Social Trade Organisation (www.socialtrade.org).
    
Cyclos is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
Cyclos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Cyclos; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    
 */

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;

import org.w3c.dom.Node;

public class Main {
    private static void write(final Node node, final Result result) {
        try {
            // Prepare the DOM document for writing
            final Source source = new DOMSource(node);

            // Write the DOM document to the file
            final Transformer xformer = TransformerFactory.newInstance().newTransformer();
            xformer.transform(source, result);
        } catch (final TransformerConfigurationException e) {
        } catch (final TransformerException e) {
        }

    }
}

Related

  1. nodeToByteArray(Node node)
  2. render(final Node node)
  3. renderNode(final Node node, final boolean stripHeader)
  4. renderNode(Node node)
  5. save(Node node, OutputStream out)