Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// publish, distribute, sublicense, and/or sell copies of the Software, 

import java.util.logging.*;

import org.w3c.dom.Node;

import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;

public class Main {
    final static Logger log = Logger.getLogger("OpenDial");

    /**
     * Serialises the XML node into a string.
     * 
     * @param node the XML node
     * @return the corresponding string
     */
    public static String serialise(Node node) {
        try {
            DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
            DOMImplementationLS lsImpl = (DOMImplementationLS) registry.getDOMImplementation("LS");
            LSSerializer serializer = lsImpl.createLSSerializer();
            return serializer.writeToString(node);
        } catch (Exception e) {
            log.fine("could not serialise XML node: " + e);
            return "";
        }
    }
}