public class XMLElement extends Object
XMLElement instance
represents a single element in a XML document.XMLDocument| Modifier and Type | Field and Description |
|---|---|
protected Writer |
writer
Writer for content output
|
| Modifier | Constructor and Description |
|---|---|
protected |
XMLElement(Writer writer,
String name)
Creates a new element for a XML document.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addChildElement(XMLElement child)
Adds the given child to this element.
|
XMLElement |
attr(String name,
int value)
Adds an attribute to this element.
|
XMLElement |
attr(String name,
long value)
Adds an attribute to this element.
|
XMLElement |
attr(String name,
String value)
Adds an attribute to this element.
|
protected void |
beginOpenTag()
Emits the beginning of the open tag.
|
void |
close()
Closes this element if it has not been closed before.
|
XMLElement |
element(String name)
Creates a new child element for this element,
|
XMLElement |
text(String text)
Adds the given text as a child to this node.
|
protected final Writer writer
protected void beginOpenTag()
throws IOException
IOException - in case of problems with the writerprotected void addChildElement(XMLElement child) throws IOException
child - child element to addIOException - in case of invalid nesting or problems with the writerpublic XMLElement attr(String name, String value) throws IOException
null the attribute will not
be added.name - attribute namevalue - attribute value or nullIOException - in case of problems with the writerpublic XMLElement attr(String name, int value) throws IOException
name - attribute namevalue - attribute valueIOException - in case of problems with the writerpublic XMLElement attr(String name, long value) throws IOException
name - attribute namevalue - attribute valueIOException - in case of problems with the writerpublic XMLElement text(String text) throws IOException
text - text to addIOException - in case of problems with the writerpublic XMLElement element(String name) throws IOException
name - name of the child elementIOException - in case of problems with the writerpublic void close()
throws IOException
IOException - in case of problems with the writerCopyright © 2024. All rights reserved.