Example usage for org.dom4j Element attributeCount

List of usage examples for org.dom4j Element attributeCount

Introduction

In this page you can find the example usage for org.dom4j Element attributeCount.

Prototype

int attributeCount();

Source Link

Document

DOCUMENT ME!

Usage

From source file:poisondog.xml.Dom4jParser.java

License:Apache License

private Node createNode(Element element) {
    Node node = new Node(element.getQName().getName());
    for (int i = 0; i < element.attributeCount(); i++) {
        Attribute attribute = element.attribute(i);
        node.setAttribute(attribute.getQName().getName(), attribute.getValue());
    }/*from  www . j  a  v a  2s .  c om*/

    for (Iterator i = element.elementIterator(); i.hasNext();) {
        Element e = (Element) i.next();
        node.addChild(createNode(e));
    }

    node.setText(element.getText());
    return node;
}

From source file:poisondog.xml.XMLUtils.java

License:Apache License

private static Node createNode(Element element) {
    Node node = new Node(element.getQName().getName());
    for (int i = 0; i < element.attributeCount(); i++) {
        Attribute attribute = element.attribute(i);
        node.setAttribute(attribute.getQName().getName(), attribute.getValue());
    }//from  w w  w .j a va2 s. c o  m

    for (Iterator i = element.elementIterator(); i.hasNext();) {
        Element e = (Element) i.next();
        node.addChild(createNode(e));
    }

    node.setText(element.getText());
    return node;
}