Java Code Examples for org.dom4j.Element.getNodeType()

The following are Jave code examples for showing how to use getNodeType() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ats-framework   File: XmlNode.java   Source Code and License Vote up 6 votes
/**
 * If some node is to be skipped, we do it in this method
 * 
 * @param matchedNode
 */
public void removeChild( Element matchedNode ) {

    // remove the matched node
    matchedNode.detach();

    // now we have to regenerate info that might have been affected
    this.value = this.node.getTextTrim();

    this.children.clear();
    List<Element> childrenElements = this.node.elements();
    for (Element child : childrenElements) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            this.children.add(new XmlNode(this, child));
        }
    }
}
 
Example 2
Project: ats-framework   File: XmlNode.java   Source Code and License Vote up 5 votes
public XmlNode( XmlNode parent, Element node ) {

        this.node = node;

        Namespace nodeNamespace = node.getNamespace();
        if (nodeNamespace != null && !StringUtils.isNullOrEmpty(nodeNamespace.getPrefix())) {
            this.name = nodeNamespace.getPrefix() + ":" + node.getName();
        } else {
            this.name = node.getName();
        }

        this.attributes = new TreeMap<>();
        for (int i = 0; i < node.attributes().size(); i++) {
            Attribute att = node.attribute(i);
            this.attributes.put(att.getName(), att.getValue());
        }

        this.value = this.node.getTextTrim();

        this.parent = parent;

        this.children = new ArrayList<>();
        List<Element> childrenElements = this.node.elements();
        for (Element child : childrenElements) {
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                this.children.add(new XmlNode(this, child));
            }
        }
    }