| Constructor and Description |
|---|
XmlWriter()
Constructs a new writer which outputs to
System.out. |
XmlWriter(PrintStream out)
Constructs a new writer which writes to a given print stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addElement(String elName,
String attList,
String content)
Writes a whole element with given attribute list and content.
|
void |
endElement(String elName)
Outputs an end element tag.
|
static String |
formatAttribute(String name,
String value)
Turns a name,value pair into an attribute assignment suitable for
putting in an XML start tag.
|
static String |
formatText(String text)
Performs necessary special character escaping for text which
will be written as XML CDATA.
|
String |
getIndent(int level)
Returns the indentation string associated with a given level.
|
int |
getLevel()
Returns the current element nesting level.
|
void |
print(String txt)
Outputs a literal string in the output.
|
void |
println(String txt)
Outputs a literal string in the output followed by a newline character.
|
void |
setOut(PrintStream out)
Sets the destination stream for this writer.
|
void |
startElement(String elName)
Outputs a start element tag with no attributes.
|
void |
startElement(String elName,
String attList)
Outputs a start element tag with a given list of attributes.
|
void |
writeDeclaration()
Writes an XML declaration.
|
public XmlWriter()
System.out.public XmlWriter(PrintStream out)
out - destination streampublic void writeDeclaration()
public void startElement(String elName)
elName - name of the elementpublic void startElement(String elName, String attList)
elName - name of the elementattList - literal string giving the attribute listpublic void endElement(String elName)
elName - name of the elementIllegalArgumentException - if that element's not ready to finishpublic void addElement(String elName, String attList, String content)
elName - name of the elementattList - literal string giving the attribute listcontent - literal string giving the element contentpublic void print(String txt)
txt - literal textpublic void setOut(PrintStream out)
out - new destination streampublic void println(String txt)
txt - literal textpublic int getLevel()
public static String formatAttribute(String name, String value)
name - the attribute namevalue - the attribute valuepublic static String formatText(String text)
text - the input texttext but with XML special characters escapedpublic String getIndent(int level)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.