Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.DOMSerializer


      outputOptions.setIndent( 4 );
      outputOptions.setMethod( "xml" );
      //if (System.getProperty("os.name").startsWith("Windows")) {
      outputOptions.setEncoding("ISO-8859-1");
      Writer writer = new BufferedWriter(new FileWriter(new File(filename)));
      DOMSerializer serializer = new XMLSerializer( writer,outputOptions );
      serializer.serialize( document );
      writer.close();
  }   
View Full Code Here


        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setMethod(Method.XML);
        of.setOmitDocumentType(true);
        of.setOmitXMLDeclaration(true);
        DOMSerializer serializer = new XMLSerializer(System.out, of);
        try {
            serializer.serialize(element);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
View Full Code Here

        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setMethod(Method.XML);
        of.setOmitDocumentType(true);
        of.setOmitXMLDeclaration(true);
        DOMSerializer serializer = new XMLSerializer(System.out, of);
        try {
            serializer.serialize(document);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
View Full Code Here

        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
    of.setEncoding("UTF-8");
        of.setMethod(Method.XML);
        FileOutputStream baos = new FileOutputStream(outputFile);
        DOMSerializer serializer = new XMLSerializer(baos, of);
        try {
            serializer.serialize(document);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
View Full Code Here

        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setMethod(Method.XML);
        of.setOmitDocumentType(true);
        of.setOmitXMLDeclaration(true);
        DOMSerializer serializer = new XMLSerializer(System.out, of);
        try {
            serializer.serialize(document);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
View Full Code Here

    private static String toString(Element element) {
        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setMethod(Method.XML);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DOMSerializer serializer = new XMLSerializer(baos, of);
        try {
            serializer.serialize(element);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return (baos.toString());
    }
View Full Code Here

    private static String toString(Document document) {
        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setMethod(Method.XML);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DOMSerializer serializer = new XMLSerializer(baos, of);
        try {
            serializer.serialize(document);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return (baos.toString());
    }
View Full Code Here

            throw new ItsNatException("INTERNAL ERROR"); // No usamos XMLSerializer
    }

    public void serializeDocument(Document doc,Writer out)
    {
        DOMSerializer serializer = getDOMSerializer(out,false);

        try
        {
            serializer.serialize(doc);
        }
        catch(IOException ex)
        {
            throw new ItsNatException(ex);
        }
View Full Code Here

    {
        try
        {
            if (node.getNodeType() == Node.ELEMENT_NODE)
            {
                DOMSerializer serializer = getDOMSerializer(out,false);
                serializer.serialize((Element)node);
            }
            else
            {
                DOMSerializer serializer = getDOMSerializer(out,true);
                DocumentFragment docFrag = node.getOwnerDocument().createDocumentFragment();
                // Tenemos que clonar porque la inserci�n en el fragmento eliminar�a el nodo del documento
                docFrag.appendChild(node.cloneNode(true));
                serializer.serialize(docFrag);
            }
        }
        catch(IOException ex)
        {
            throw new ItsNatDOMException(ex,node);
View Full Code Here

TOP

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

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.