Java XML Node Transform createInputStream(Node node)

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

Description

create Input Stream

License

BSD License

Declaration

public static InputStream createInputStream(Node node) throws TransformerException 

Method Source Code


//package com.java2s;
/*//  w  w w.ja  v a 2s .c o m
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.Node;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class Main {
    public static InputStream createInputStream(Node node) throws TransformerException {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        TransformerFactory.newInstance().newTransformer().transform(new DOMSource(node), new StreamResult(stream));
        return new ByteArrayInputStream(stream.toByteArray());
    }
}

Related

  1. buildXml(Node node)
  2. copyTreeToResult(Node tree, Result result)
  3. createXML(Node doc)
  4. getAsText(Node n)
  5. getHumanReadableXml(final Node node)
  6. getNodeValue(NodeList nodeList)