Convert Node to XML Element - Java XML

Java examples for XML:DOM Node

Description

Convert Node to XML Element

Demo Code


import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main{
    public static Element toElement(Node node) throws XMLHelperException {
        if (node.getNodeType() != Node.ELEMENT_NODE)
            throw new XMLHelperException("\"" + node.getNodeName()
                    + "\" must be an element node");
        return (Element) node;
    }//from   w  ww .j av  a2 s.c o  m
}

Related Tutorials