Java XML Node Serialize serializeNode(Node node)

Here you can find the source of serializeNode(Node node)

Description

serialize Node

License

Open Source License

Declaration

public static String serializeNode(Node node) throws LSException, IllegalAccessException, DOMException,
            InstantiationException, ClassNotFoundException, ClassCastException 

Method Source Code

//package com.java2s;

import org.w3c.dom.DOMException;
import org.w3c.dom.Document;

import org.w3c.dom.Node;

import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSException;

import org.w3c.dom.ls.LSSerializer;

public class Main {
    public static String serializeNode(Node node) throws LSException, IllegalAccessException, DOMException,
            InstantiationException, ClassNotFoundException, ClassCastException {
        String serializedElement = null;
        if (node != null) {
            DOMImplementationLS impl = getDOMImplementationLS(node);
            LSSerializer writer = impl.createLSSerializer();
            serializedElement = writer.writeToString(node);
        }/*  www . j  a v a 2s  .co  m*/
        return serializedElement;
    }

    protected static DOMImplementationLS getDOMImplementationLS(Node node) {
        Document document = node.getOwnerDocument();
        return (DOMImplementationLS) document.getImplementation();
    }
}

Related

  1. serialize(NodeList nodeList)
  2. serializeDom(Node domElement)
  3. serializeDom(Node node, StringBuffer writeString)
  4. serializeElement(Element element)
  5. serializeElement(Element element, boolean omitXmlDeclaration, boolean indent, String method)
  6. serializeNode(Node node)
  7. serializeNode(Node node)
  8. serializeNode(Node node)
  9. serializeNode(Node node)