public class DOMSerializer
extends java.lang.Object
Constructor and Description |
---|
DOMSerializer() |
Modifier and Type | Method and Description |
---|---|
void |
serialize(org.w3c.dom.Document doc,
java.io.File file)
Serialize
doc to out |
void |
serialize(org.w3c.dom.Document doc,
java.io.OutputStream out)
Serialize
doc to out |
void |
setEncoding(java.lang.String encoding)
Set the encoding used by this serializer.
|
void |
setIndent(int indent)
Set the number of spaces to use for indentation.
|
void |
setLineSeparator(java.lang.String lineSeparator)
Set the line separator that will be used when serializing documents.
|
public void serialize(org.w3c.dom.Document doc, java.io.File file) throws java.io.IOException
doc
to out
doc
- the document to serialize.file
- the file to serialize to.java.io.IOException
public void serialize(org.w3c.dom.Document doc, java.io.OutputStream out) throws java.io.IOException
doc
to out
doc
- the document to serialize.out
- the stream to serialize to.java.io.IOException
public void setEncoding(java.lang.String encoding)
encoding
- the encoding to use, passing in null
results in the
default encoding (UTF-8) being set.public void setIndent(int indent)
The default is to use 4 spaces.
indent
- the number of spaces to use for indentation, values less than or
equal to zero result in no indentation being used.public void setLineSeparator(java.lang.String lineSeparator)
If this is not called then the serializer uses a default based on the
line.separator
system property.
lineSeparator
- the line separator to set.