public class XmlElement extends Object
Constructor and Description |
---|
XmlElement()
Create a new XmlElement of unknown type.
|
XmlElement(String type)
Create a new XmlElement with element type given by the string.
|
XmlElement(String type,
Map attrs)
Create a new XmlElement with element type with the given name and the
given attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(XmlElement e)
Add a child element to this element.
|
void |
appendPCData(String s)
Add the String to the end of the current PCDATA for this element.
|
Iterator |
attributeNames()
Return an enumeration over the names of the attributes
in this schematic.
|
boolean |
containsElement(XmlElement elt)
Test if this element contains the given element.
|
int |
elementCount()
Return the number of child elements.
|
Iterator |
elements()
Return an Iterator of all the child elements of this element.
|
Iterator |
elements(String type)
Return an Iterator of all the child elements of this element that
have the given element type.
|
String |
getAttribute(String name)
Return the value of the attribute with the given name,
or null if there isn't one.
|
Map |
getAttributeMap()
Return the map from attribute names to value.
|
List |
getChildList()
Return the list of child elements.
|
XmlElement |
getElement(String type)
Return the first child element of this element with the given type,
or null if there isn't one.
|
XmlElement |
getElement(String type,
String name)
Return the first child element of this element with the given type
and name, or null if there isn't one.
|
XmlElement |
getParent()
Return the parent element of this element, or null if it has no
parent.
|
String |
getPCData()
Return the PCData that is associated with this XmlElement.
|
String |
getType()
Return the type of this XmlElement.
|
boolean |
hasAttribute(String name)
Test if this element has the attribute with the given name.
|
void |
removeAttribute(String name)
Remove an attribute from this element
|
void |
removeElement(XmlElement e)
Remove a child element from this element
|
void |
setAttribute(String name,
String value)
Set the attribute with the given name to the given value.
|
void |
setParent(XmlElement p)
Set the parent element of this element.
|
void |
setPCData(String s)
Set the text of this element to the given string.
|
void |
setType(String s)
Set the type of this element
|
String |
toString()
Convert this element to a string in XML
|
void |
writeXML(Writer out,
String prefix)
Print this element to a Writer
|
public XmlElement(String type)
name
- The element typepublic XmlElement()
public void addElement(XmlElement e)
public void appendPCData(String s)
public Iterator attributeNames()
public boolean containsElement(XmlElement elt)
public int elementCount()
public Iterator elements()
public Iterator elements(String type)
public String getAttribute(String name)
public Map getAttributeMap()
public List getChildList()
public XmlElement getElement(String type)
public XmlElement getElement(String type, String name)
public String getType()
public XmlElement getParent()
public String getPCData()
public boolean hasAttribute(String name)
public void removeAttribute(String name)
public void removeElement(XmlElement e)
public void setAttribute(String name, String value)
public void setParent(XmlElement p)
public void setPCData(String s)
public void setType(String s)
public String toString()
public void writeXML(Writer out, String prefix) throws IOException
IOException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.