Home » dom4j-1.6.1 » org.dom4j » [javadoc | source]
org.dom4j
public interface: Element [javadoc | source]

All Implemented Interfaces:
    Branch

All Known Implementing Classes:
    BaseElement, NonLazyElement, DatatypeElement, DefaultElement, DOMElement, AbstractElement, UserDataElement, BeanElement, LElement, IndexedElement

Element interface defines an XML element. An element can have declared namespaces, attributes, child nodes and textual content.

Some of this interface is optional. Some implementations may be read-only and not support being modified. Some implementations may not support the parent relationship and methods such as #getParent or {@link#getDocument}.

Method from org.dom4j.Element Summary:
add,   add,   add,   add,   add,   addAttribute,   addAttribute,   addCDATA,   addComment,   addEntity,   addNamespace,   addProcessingInstruction,   addProcessingInstruction,   addText,   additionalNamespaces,   appendAttributes,   attribute,   attribute,   attribute,   attributeCount,   attributeIterator,   attributeValue,   attributeValue,   attributeValue,   attributeValue,   attributes,   createCopy,   createCopy,   createCopy,   declaredNamespaces,   element,   element,   elementIterator,   elementIterator,   elementIterator,   elementText,   elementText,   elementTextTrim,   elementTextTrim,   elements,   elements,   elements,   getData,   getNamespace,   getNamespaceForPrefix,   getNamespaceForURI,   getNamespacePrefix,   getNamespaceURI,   getNamespacesForURI,   getQName,   getQName,   getQualifiedName,   getStringValue,   getText,   getTextTrim,   getXPathResult,   hasMixedContent,   isRootElement,   isTextOnly,   remove,   remove,   remove,   remove,   remove,   setAttributeValue,   setAttributeValue,   setAttributes,   setData,   setQName
Method from org.dom4j.Element Detail:
 public  void add(Attribute attribute)
    Adds the given Attribute to this element. If the given node already has a parent defined then an IllegalAddException will be thrown. Attributes with null values are silently ignored.

    If the value of the attribute is null then this method call will remove any attributes with the QName of this attribute.

 public  void add(CDATA cdata)
    Adds the given CDATA to this element. If the given node already has a parent defined then an IllegalAddException will be thrown.
 public  void add(Entity entity)
    Adds the given Entity to this element. If the given node already has a parent defined then an IllegalAddException will be thrown.
 public  void add(Text text)
    Adds the given Text to this element. If the given node already has a parent defined then an IllegalAddException will be thrown.
 public  void add(Namespace namespace)
    Adds the given Namespace to this element. If the given node already has a parent defined then an IllegalAddException will be thrown.
 public Element addAttribute(String name,
    String value)

    Adds the attribute value of the given local name. If an attribute already exists for the given name it will be replaced. Attributes with null values are silently ignored. If the value of the attribute is null then this method call will remove any attributes with the given name.

 public Element addAttribute(QName qName,
    String value)

    Adds the attribute value of the given fully qualified name. If an attribute already exists for the given name it will be replaced. Attributes with null values are silently ignored. If the value of the attribute is null then this method call will remove any attributes with the given name.

 public Element addCDATA(String cdata)
    Adds a new CDATA node with the given text to this element.
 public Element addComment(String comment)
    Adds a new Comment node with the given text to this element.
 public Element addEntity(String name,
    String text)
    Adds a new Entity node with the given name and text to this element and returns a reference to the new node.
 public Element addNamespace(String prefix,
    String uri)
    Adds a namespace to this element for use by its child content
 public Element addProcessingInstruction(String target,
    String text)
    Adds a processing instruction for the given target
 public Element addProcessingInstruction(String target,
    Map data)
    Adds a processing instruction for the given target
 public Element addText(String text)
    Adds a new Text node with the given text to this element.
 public List additionalNamespaces()

    Returns any additional namespaces declarations for this element other than namespace returned via the #getNamespace() method. If no additional namespace declarations are present for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.

 public  void appendAttributes(Element element)
 public Attribute attribute(int index)
    Returns the attribute at the specified indexGets the
 public Attribute attribute(String name)
    Returns the attribute with the given name
 public Attribute attribute(QName qName)
    DOCUMENT ME!
 public int attributeCount()
    DOCUMENT ME!
 public Iterator attributeIterator()
    DOCUMENT ME!
 public String attributeValue(String name)

    This returns the attribute value for the attribute with the given name and any namespace or null if there is no such attribute or the empty string if the attribute value is empty.

 public String attributeValue(QName qName)

    This returns the attribute value for the attribute with the given fully qualified name or null if there is no such attribute or the empty string if the attribute value is empty.

 public String attributeValue(String name,
    String defaultValue)

    This returns the attribute value for the attribute with the given name and any namespace or the default value if there is no such attribute value.

 public String attributeValue(QName qName,
    String defaultValue)

    This returns the attribute value for the attribute with the given fully qualified name or the default value if there is no such attribute value.

 public List attributes()

    Returns the Attribute instances this element contains as a backed List so that the attributes may be modified directly using the List interface. The List is backed by the Element so that changes to the list are reflected in the element and vice versa.

 public Element createCopy()

    Creates a deep copy of this element The new element is detached from its parent, and getParent() on the clone will return null.

 public Element createCopy(String name)

    Creates a deep copy of this element with the given local name The new element is detached from its parent, and getParent() on the clone will return null.

 public Element createCopy(QName qName)

    Creates a deep copy of this element with the given fully qualified name. The new element is detached from its parent, and getParent() on the clone will return null.

 public List declaredNamespaces()

    Returns all the namespaces declared by this element. If no namespaces are declared for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.

 public Element element(String name)
    Returns the first element for the given local name and any namespace.
 public Element element(QName qName)
    Returns the first element for the given fully qualified name.
 public Iterator elementIterator()
    Returns an iterator over all this elements child elements.
 public Iterator elementIterator(String name)
    Returns an iterator over the elements contained in this element which match the given local name and any namespace.
 public Iterator elementIterator(QName qName)
    Returns an iterator over the elements contained in this element which match the given fully qualified name.
 public String elementText(String name)
 public String elementText(QName qname)
 public String elementTextTrim(String name)
 public String elementTextTrim(QName qname)
 public List elements()

    Returns the elements contained in this element. If this element does not contain any elements then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.

 public List elements(String name)

    Returns the elements contained in this element with the given local name and any namespace. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.

 public List elements(QName qName)

    Returns the elements contained in this element with the given fully qualified name. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.

 public Object getData()
    Accesses the data of this element which may implement data typing bindings such as XML Schema or Java Bean bindings or will return the same value as #getText
 public Namespace getNamespace()

    Returns the Namespace of this element if one exists otherwise Namespace.NO_NAMESPACE is returned.

 public Namespace getNamespaceForPrefix(String prefix)

    Returns the Namespace which is mapped to the given prefix or null if it could not be found.

 public Namespace getNamespaceForURI(String uri)

    Returns the Namespace which is mapped to the given URI or null if it could not be found. If there is more than one Namespace mapped to the URI, which of them will be returned is undetermined.

 public String getNamespacePrefix()

    Returns the namespace prefix of this element if one exists otherwise an empty String is returned.

 public String getNamespaceURI()

    Returns the URI mapped to the namespace of this element if one exists otherwise an empty String is returned.

 public List getNamespacesForURI(String uri)

    Returns the all namespaces which are mapped to the given URI or an empty list if no such namespaces could be found.

 public QName getQName()

    Returns the QName of this element which represents the local name, the qualified name and the Namespace.

 public QName getQName(String qualifiedName)

    Returns the QName for the given qualified name, using the namespace URI in scope for the given prefix of the qualified name or the default namespace if the qualified name has no prefix.

 public String getQualifiedName()

    Returns the fully qualified name of this element. This will be the same as the value returned from #getName if this element has no namespace attached to this element or an expression of the form

    getNamespacePrefix() + ":" + getName()
    
    will be returned.

 public String getStringValue()
    Returns the XPath string-value of this node. The behaviour of this method is defined in the XPath specification . This method returns the string-value of all the contained Text ,CDATA ,Entity and Element nodes all appended together.
 public String getText()
    Returns the text value of this element without recursing through child elements. This method iterates through all Text ,CDATA and Entity nodes that this element contains and appends the text values together.
 public String getTextTrim()
    DOCUMENT ME!
 public Node getXPathResult(int index)
    Returns a node at the given index suitable for an XPath result set. This means the resulting Node will either be null or it will support the parent relationship.
 public boolean hasMixedContent()

    Returns true if this Element has mixed content. Mixed content means that an element contains both textual data and child elements.

 public boolean isRootElement()
    DOCUMENT ME!
 public boolean isTextOnly()

    Returns true if this Element has text only content.

 public boolean remove(Attribute attribute)
    Removes the given Attribute from this element.
 public boolean remove(CDATA cdata)
    Removes the given CDATA if the node is an immediate child of this element. If the given node is not an immediate child of this element then the Node#detach() method should be used instead.
 public boolean remove(Entity entity)
    Removes the given Entity if the node is an immediate child of this element. If the given node is not an immediate child of this element then the Node#detach() method should be used instead.
 public boolean remove(Namespace namespace)
    Removes the given Namespace if the node is an immediate child of this element. If the given node is not an immediate child of this element then the Node#detach() method should be used instead.
 public boolean remove(Text text)
    Removes the given Text if the node is an immediate child of this element. If the given node is not an immediate child of this element then the Node#detach() method should be used instead.
 public  void setAttributeValue(String name,
    String value)Deprecated! As -  of version 0.5. Please use #addAttribute(String,String)  instead. WILL BE REMOVED IN
dom4j-1.6 !!

    Sets the attribute value of the given local name.

 public  void setAttributeValue(QName qName,
    String value)Deprecated! As -  of version 0.5. Please use #addAttribute(QName,String)  instead. WILL BE REMOVED IN
dom4j-1.6 !!

    Sets the attribute value of the given fully qualified name.

 public  void setAttributes(List attributes)
    Sets the attributes that this element contains
 public  void setData(Object data)
    Sets the data value of this element if this element supports data binding or calls #setText if it doesn't
 public  void setQName(QName qname)

    Sets the QName of this element which represents the local name, the qualified name and the Namespace.