de.zeigermann.xml
Class XMLStringWriter
public class XMLStringWriter
This is a convenience class for writing XML to a string. As
no IOExceptions will occur this class catches them for you
doing nothing. Call
toString()
to finally get your string.
As constructor for
XMLWriter
already needs writer call
create()
to get your objects instead of consructor.
static XMLStringWriter | create() - Creates a new
XMLStringWriter objects.
|
String | toString() - Gets the string representation of your written XML.
|
void | writeCData(String cData) - Writes character data with encoding.
|
void | writeComment(String comment) - Writes
comment encoded as comment.
|
void | writeElementWithCData(String startTag, String cData, String endTag) - Writes a full element consisting of a start tag, character data and
an end tag.
|
void | writeElementWithPCData(String startTag, String pcData, String endTag) - Writes a full element consisting of a start tag, character data and
an end tag.
|
void | writeEmptyElement(String emptyTag) - Writes an empty element.
|
void | writeEmptyElement(String emptyTag, boolean nl) - Writes an empty element.
|
void | writeEndTag(String endTag) - Writes an end tag.
|
void | writeEndTag(String endTag, boolean nl) - Writes an end tag.
|
void | writeNl() - Writes a single newline.
|
void | writePCData(String pcData) - Writes character data without encoding.
|
void | writePI(String target, String data) - Writes a processing instruction.
|
void | writeProlog(String prolog) - Writes prolog data like doctype delcaration and
DTD parts followed by a newline.
|
void | writeStartTag(String startTag) - Writes a start tag.
|
void | writeStartTag(String startTag, boolean nl) - Writes a start tag.
|
void | writeXMLDeclaration() - Writes XML declaration.
|
createEmptyTag , createEmptyTag , createEmptyTag , createEmptyTag , createEmptyTag , createEndTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , generateAndWriteElementWithCData , generateAndWriteElementWithCData , getNlAfterEmptyTag , getNlAfterEndTag , getNlAfterStartTag , getPrettyPrintMode , getTabWidth , isXMLDeclarationWritten , setNlAfterEmptyTag , setNlAfterEndTag , setNlAfterStartTag , setPrettyPrintMode , setTabWidth , setXMLDeclarationWritten , writeCData , writeComment , writeElementWithCData , writeElementWithPCData , writeEmptyElement , writeEmptyElement , writeEndTag , writeEndTag , writeNl , writePCData , writePI , writeProlog , writeStartTag , writeStartTag , writeXMLDeclaration |
create
public static XMLStringWriter create()
Creates a new XMLStringWriter
objects.
toString
public String toString()
Gets the string representation of your written XML.
writeCData
public void writeCData(String cData)
Writes character data with encoding.
- writeCData in interface XMLWriter
cData
- the character data to write
writeComment
public void writeComment(String comment)
Writes comment
encoded as comment.
- writeComment in interface XMLWriter
writeElementWithCData
public void writeElementWithCData(String startTag,
String cData,
String endTag)
Writes a full element consisting of a start tag, character data and
an end tag. There will be no newline after start tag, so character data
is literally preserved.
The character data will be encoded.
- writeElementWithCData in interface XMLWriter
startTag
- the complete start tag, e.g. <element>
cData
- the character data to writeendTag
- the complete end tag, e.g. </element>
writeElementWithPCData
public void writeElementWithPCData(String startTag,
String pcData,
String endTag)
Writes a full element consisting of a start tag, character data and
an end tag. There will be no newline after start tag, so character data
is literally preserved.
The character data will not be encoded.
- writeElementWithPCData in interface XMLWriter
startTag
- the complete start tag, e.g. <element>
pcData
- the parseable character data to writeendTag
- the complete end tag, e.g. </element>
writeEmptyElement
public void writeEmptyElement(String emptyTag)
Writes an empty element.
- writeEmptyElement in interface XMLWriter
emptyTag
- the complete tag for an empty element, e.g. <start/>
writeEmptyElement
public void writeEmptyElement(String emptyTag,
boolean nl)
Writes an empty element.
- writeEmptyElement in interface XMLWriter
emptyTag
- the complete tag for an empty element, e.g. <empty/>
nl
- decides whether there should be a newline after the tag
writeEndTag
public void writeEndTag(String endTag)
Writes an end tag.
- writeEndTag in interface XMLWriter
endTag
- the complete end tag, e.g. </end>
writeEndTag
public void writeEndTag(String endTag,
boolean nl)
Writes an end tag.
- writeEndTag in interface XMLWriter
endTag
- the complete end tag, e.g. </end>
nl
- decides whether there should be a newline after the tag
writeNl
public void writeNl()
Writes a single newline.
- writeNl in interface XMLWriter
writePCData
public void writePCData(String pcData)
Writes character data without encoding.
- writePCData in interface XMLWriter
pcData
- the parseable character data to write
writePI
public void writePI(String target,
String data)
Writes a processing instruction.
- writePI in interface XMLWriter
writeProlog
public void writeProlog(String prolog)
Writes prolog data like doctype delcaration and
DTD parts followed by a newline.
Do not misuse this to write plain text, but rather - if you really
have to - use the standard XMLWriter
methods.
- writeProlog in interface XMLWriter
writeStartTag
public void writeStartTag(String startTag)
Writes a start tag.
- writeStartTag in interface XMLWriter
startTag
- the complete start tag, e.g. <start>
writeStartTag
public void writeStartTag(String startTag,
boolean nl)
Writes a start tag.
- writeStartTag in interface XMLWriter
startTag
- the complete start tag, e.g. <start>
nl
- decides whether there should be a newline after the tag
writeXMLDeclaration
public void writeXMLDeclaration()
Writes XML declaration.
XML declaration will be written
using version 1.0 and no encoding defaulting
to standard encoding (supports UTF-8 and UTF-16):
<?xml version="1.0"?>
If you want to have a different encoding or the standalone declaration
use
XMLWriter.writeProlog(String)
.
This sets
xmlDeclWritten
to
true
.
- writeXMLDeclaration in interface XMLWriter
Copyright © 2002-2004 Oliver Zeigermann. All Rights Reserved.