public class Element extends Node
<tagName attr1="value1" attr2="value2"> text <childTag...> <childTag...> text <childTag...> text </tagName>
Copyright (C) 2002 Hewlett-Packard Company. This file is part of Sparta, an XML Parser, DOM, and XPath library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Element| Modifier and Type | Method and Description |
|---|---|
void |
appendChild(Node addedChild)
Add node as child of this element, cloning node if it is this element or
an ancestor.
|
Object |
clone()
Create a deep clone of this Element.
|
Element |
cloneElement(boolean deep)
Create a clone of this node.
|
Element |
cloneShallow()
Create a shallow clone of this Element.
|
protected int |
computeHashCode()
Called whenever cached version of hashCode needs to be regenerated.
|
boolean |
equals(Object thatO)
To be equal elements must have the same tagname, they must
have the same children (applying equals recursivly) in the
same order and they must have the same attributes in any
order.
|
String |
getAttribute(String name) |
Enumeration |
getAttributeNames()
Return enumeration of Strings
|
Node |
getFirstChild() |
Node |
getLastChild() |
String |
getTagName() |
void |
removeAttribute(String name)
remove this attribute if it exists, otherwise silently do nothing.
|
void |
removeChild(Node childToRemove) |
void |
replaceChild(Element newChild,
Node oldChild)
Replace oldChild with newChild.
|
void |
replaceChild(Text newChild,
Node oldChild)
Replace oldChild with newChild.
|
void |
setAttribute(String name,
String value) |
void |
setTagName(String tagName) |
void |
toXml(Writer writer)
Write XML representation to character stream.
|
boolean |
xpathEnsure(String xpath)
Make sure this XPath exists, creating nodes if necessary,
returning true if any nodes created.
|
Element |
xpathSelectElement(String xpath)
Select the first element that matches the relative XPath
expression with respect to this element, or null if
there is no match.
|
Enumeration |
xpathSelectElements(String xpath)
Select all the elements that match the relative XPath
expression with respect to this element.
|
String |
xpathSelectString(String xpath)
Select the first element that matches the relative XPath
expression with respect to this element, or null if
there is no match.
|
Enumeration |
xpathSelectStrings(String xpath)
Select all the strings that match the relative XPath
expression with respect to this element.
|
getAnnotation, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, hashCode, htmlEncode, setAnnotation, toString, toXml, xpathSetStringspublic Element(String tagName)
public Object clone()
public Element cloneShallow()
public Element cloneElement(boolean deep)
public String getTagName()
public void setTagName(String tagName)
public Node getFirstChild()
public Node getLastChild()
public Enumeration getAttributeNames()
public String getAttribute(String name)
public void setAttribute(String name, String value)
name - attribute name which must be non-null, non emptyvalue - attribue value.public void removeAttribute(String name)
public void appendChild(Node addedChild)
public void removeChild(Node childToRemove) throws DOMException
DOMExceptionpublic void replaceChild(Element newChild, Node oldChild) throws DOMException
DOMException - if oldChild object is not a child.public void replaceChild(Text newChild, Node oldChild) throws DOMException
DOMException - if oldChild object is not a child.public void toXml(Writer writer) throws IOException
IOExceptionpublic Enumeration xpathSelectElements(String xpath) throws ParseException
xpathSelectElements in class NodeParseExceptionpublic Enumeration xpathSelectStrings(String xpath) throws ParseException
xpathSelectStrings in class NodeParseExceptionpublic boolean xpathEnsure(String xpath) throws ParseException
ParseExceptionpublic Element xpathSelectElement(String xpath) throws ParseException
xpathSelectElement in class NodeParseExceptionpublic String xpathSelectString(String xpath) throws ParseException
xpathSelectString in class NodeParseExceptionpublic boolean equals(Object thatO)
protected int computeHashCode()
computeHashCode in class NodeCopyright © 2016. All Rights Reserved.