HTMLElement
, XMLDocument
public class XMLElement
extends java.lang.Object
XMLElement
instance
represents a single element in a XML document.XMLDocument
Modifier and Type | Field | Description |
---|---|---|
protected java.io.Writer |
writer |
Writer for content output
|
Modifier | Constructor | Description |
---|---|---|
protected |
XMLElement(java.io.Writer writer,
java.lang.String name) |
Creates a new element for a XML document.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
addChildElement(XMLElement child) |
Adds the given child to this element.
|
XMLElement |
attr(java.lang.String name,
int value) |
Adds an attribute to this element.
|
XMLElement |
attr(java.lang.String name,
long value) |
Adds an attribute to this element.
|
XMLElement |
attr(java.lang.String name,
java.lang.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(java.lang.String name) |
Creates a new child element for this element,
|
XMLElement |
text(java.lang.String text) |
Adds the given text as a child to this node.
|
protected XMLElement(java.io.Writer writer, java.lang.String name)
writer
- all output will be written directly to thisname
- element nameprotected void beginOpenTag() throws java.io.IOException
java.io.IOException
- in case of problems with the writerprotected void addChildElement(XMLElement child) throws java.io.IOException
child
- child element to addjava.io.IOException
- in case of invalid nesting or problems with the writerpublic XMLElement attr(java.lang.String name, java.lang.String value) throws java.io.IOException
null
the attribute will not
be added.name
- attribute namevalue
- attribute value or null
java.io.IOException
- in case of problems with the writerpublic XMLElement attr(java.lang.String name, int value) throws java.io.IOException
name
- attribute namevalue
- attribute valuejava.io.IOException
- in case of problems with the writerpublic XMLElement attr(java.lang.String name, long value) throws java.io.IOException
name
- attribute namevalue
- attribute valuejava.io.IOException
- in case of problems with the writerpublic XMLElement text(java.lang.String text) throws java.io.IOException
text
- text to addjava.io.IOException
- in case of problems with the writerpublic XMLElement element(java.lang.String name) throws java.io.IOException
name
- name of the child elementjava.io.IOException
- in case of problems with the writerpublic void close() throws java.io.IOException
java.io.IOException
- in case of problems with the writerCopyright © 2018. All rights reserved.