public class Document extends NodeWithChildren implements Parent
If you add a ProcessingInstruction as the first node of the document,
it will be converted into an XMLDeclaration.
Note: The automatic creation of XMLDeclaration is not perfect; if you
manipulate the list of nodes yourself (for example, via getNodes().add()),
then you're on your own.
| Modifier and Type | Field and Description |
|---|---|
private DocType |
docType |
private Namespaces |
namespaces |
private Element |
rootNode |
private XMLDeclaration |
xmlDeclaration |
| Modifier and Type | Method and Description |
|---|---|
Document |
addNode(int index,
Node node) |
Document |
addNode(Node node) |
Document |
addNodes(java.util.Collection<? extends Node> nodes) |
Document |
addNodes(int index,
java.util.Collection<? extends Node> nodes) |
Document |
addNodes(int index,
Node... nodes) |
Document |
addNodes(Node... nodes) |
protected void |
clearXMLDeclaration() |
Document |
copy()
Simulate clone()
|
Document |
copy(Node orig)
Copy all data from
orig into this |
Document |
createClone()
Simulate clone()
|
protected XMLDeclaration |
createXMLDeclaration() |
Element |
getChild(java.lang.String path)
Find a child element (not a node!) by path
|
Element |
getChild(java.lang.String path,
Namespace ns) |
DocType |
getDocType() |
java.lang.String |
getEncoding() |
Namespace |
getNamespace(java.lang.String prefix) |
Namespaces |
getNamespaces() |
Element |
getRootElement() |
XMLTokenizer.Type |
getType()
Get the node type
|
java.lang.String |
getVersion() |
XMLDeclaration |
getXmlDeclaration() |
boolean |
isStandalone() |
TreeIterator |
iterator() |
void |
parseXMLDeclaration()
Parse a possible XML declaration and fill the internal fields with the data.
|
Node |
removeNode(int index)
Remove a node from the list
|
boolean |
removeNode(Node n)
Remove a node from the list
|
void |
setDocType(DocType docType) |
Document |
setEncoding(java.lang.String encoding) |
void |
setNamespaces(Namespaces namespaces) |
Document |
setRootNode(Element rootNode) |
void |
setStandalone(boolean standalone) |
Document |
setVersion(java.lang.String version) |
void |
setXmlDeclaration(XMLDeclaration xmlDeclaration) |
Document |
toXML(XMLWriter writer)
Fast way to convert many nodes to XML
|
clearNodes, getNode, getNodes, getNodes, hasNodes, nodeCount, nodeIndexOf, toString, toXMLclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclearNodes, getNode, getNodes, hasNodes, nodeCount, nodeIndexOfprivate Element rootNode
private XMLDeclaration xmlDeclaration
private DocType docType
private Namespaces namespaces
public Document()
public Document(Node... nodes)
public Document addNode(Node node)
addNode in interface ParentaddNode in class NodeWithChildrenpublic Document addNode(int index, Node node)
addNode in interface ParentaddNode in class NodeWithChildrenpublic Document addNodes(java.util.Collection<? extends Node> nodes)
addNodes in interface ParentaddNodes in class NodeWithChildrenpublic Document addNodes(int index, java.util.Collection<? extends Node> nodes)
addNodes in interface ParentaddNodes in class NodeWithChildrenpublic Document addNodes(Node... nodes)
addNodes in interface ParentaddNodes in class NodeWithChildrenpublic Document addNodes(int index, Node... nodes)
addNodes in interface ParentaddNodes in class NodeWithChildrenpublic Node removeNode(int index)
ParentremoveNode in interface ParentremoveNode in class NodeWithChildrenpublic boolean removeNode(Node n)
ParentremoveNode in interface ParentremoveNode in class NodeWithChildrenpublic Element getChild(java.lang.String path)
Parentpublic XMLTokenizer.Type getType()
Nodepublic Element getRootElement()
public XMLDeclaration getXmlDeclaration()
public void setXmlDeclaration(XMLDeclaration xmlDeclaration)
public java.lang.String getVersion()
public Document setVersion(java.lang.String version)
protected XMLDeclaration createXMLDeclaration()
public java.lang.String getEncoding()
public Document setEncoding(java.lang.String encoding)
public boolean isStandalone()
public void setStandalone(boolean standalone)
public Document toXML(XMLWriter writer) throws java.io.IOException
NodetoXML in interface NodetoXML in class NodeWithChildrenjava.io.IOExceptionpublic void parseXMLDeclaration()
protected void clearXMLDeclaration()
public DocType getDocType()
public void setDocType(DocType docType)
public Namespaces getNamespaces()
public void setNamespaces(Namespaces namespaces)
public Namespace getNamespace(java.lang.String prefix)
public Document createClone()
NodecreateClone in interface Nodepublic Document copy(Node orig)
Nodeorig into thiscopy in interface Nodecopy in class NodeWithChildrenpublic Document copy()
Nodecopy in interface Nodecopy in class NodeWithChildrenpublic TreeIterator iterator()