Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.XML11Serializer


        ", but you passed in " + node.getClass().getName() + '!', node
      );
    }
    OutputFormat format;
    StringWriter stringOut;
    XML11Serializer serial;
    if (node.getOwnerDocument() == null) {
      format = new OutputFormat(org.apache.xml.serialize.Method.XML, null, true);
    } else {
      format = new OutputFormat(node.getOwnerDocument(), null, true);
    }
    format.setOmitXMLDeclaration(true);
    if (indent) {
      format.setIndent(2);
      format.setLineSeparator("\r\n");
    } else {
      format.setIndent(0);
      format.setLineSeparator("");
    }
    stringOut = new StringWriter();
    serial = new XML11Serializer(stringOut, format);
    serial.setNamespaces(true);

    // serial.asDOMSerializer();

    try {
      if (node instanceof Element) {
        serial.serialize((Element) node);
      } else if (node instanceof Document) {
        serial.serialize((Document) node);
      } else {
        serial.serialize((DocumentFragment) node);
      }
      return stringOut.toString();
    } catch (java.io.IOException ioe) {
      throw new IOErrorRuntimeException("Strange error. IOException occurred where it cannot!", ioe);
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.serialize.XML11Serializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.