public class XmlWriter
extends java.io.Writer
StringWriter writer = new StringWriter();
XmlWriter xml = new XmlWriter(writer);
xml.element("meow")
.attribute("moo", "cow")
.element("child")
.attribute("moo", "cow")
.element("child")
.attribute("moo", "cow")
.text("XML is like violence. If it doesn't solve your problem, you're not using enough of it.")
.pop()
.pop()
.pop();
System.out.println(writer);
| Modifier and Type | Field and Description |
|---|---|
int |
indent |
| Constructor and Description |
|---|
XmlWriter(java.io.Writer writer) |
| Modifier and Type | Method and Description |
|---|---|
XmlWriter |
attribute(java.lang.String name,
java.lang.Object value) |
void |
close()
Calls
pop() for each remaining open element, if any, and closes the stream. |
XmlWriter |
element(java.lang.String name) |
XmlWriter |
element(java.lang.String name,
java.lang.Object text) |
void |
flush() |
XmlWriter |
pop() |
XmlWriter |
text(java.lang.Object text) |
void |
write(char[] cbuf,
int off,
int len) |
public XmlWriter element(java.lang.String name) throws java.io.IOException
java.io.IOExceptionpublic XmlWriter element(java.lang.String name, java.lang.Object text) throws java.io.IOException
java.io.IOExceptionpublic XmlWriter attribute(java.lang.String name, java.lang.Object value) throws java.io.IOException
java.io.IOExceptionpublic XmlWriter text(java.lang.Object text) throws java.io.IOException
java.io.IOExceptionpublic XmlWriter pop() throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
pop() for each remaining open element, if any, and closes the stream.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOException