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 | Method and Description |
---|---|
Document |
addNode(int index,
Node node) |
Document |
addNode(Node node) |
Document |
addNodes(Collection<? extends Node> nodes) |
Document |
addNodes(int index,
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(String path)
Find a child element (not a node!) by path
|
Element |
getChild(String path,
Namespace ns) |
DocType |
getDocType() |
String |
getEncoding() |
Namespace |
getNamespace(String prefix) |
Namespaces |
getNamespaces() |
Element |
getRootElement() |
XMLTokenizer.Type |
getType()
Get the node type
|
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(String encoding) |
void |
setNamespaces(Namespaces namespaces) |
Document |
setRootNode(Element rootNode) |
void |
setStandalone(boolean standalone) |
Document |
setVersion(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, toXML
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clearNodes, getNode, getNodes, hasNodes, nodeCount, nodeIndexOf
public Document()
public Document(Node... nodes)
public Document addNode(Node node)
addNode
in interface Parent
addNode
in class NodeWithChildren
public Document addNode(int index, Node node)
addNode
in interface Parent
addNode
in class NodeWithChildren
public Document addNodes(Collection<? extends Node> nodes)
addNodes
in interface Parent
addNodes
in class NodeWithChildren
public Document addNodes(int index, Collection<? extends Node> nodes)
addNodes
in interface Parent
addNodes
in class NodeWithChildren
public Document addNodes(Node... nodes)
addNodes
in interface Parent
addNodes
in class NodeWithChildren
public Document addNodes(int index, Node... nodes)
addNodes
in interface Parent
addNodes
in class NodeWithChildren
public Node removeNode(int index)
Parent
removeNode
in interface Parent
removeNode
in class NodeWithChildren
public boolean removeNode(Node n)
Parent
removeNode
in interface Parent
removeNode
in class NodeWithChildren
public Element getChild(String path)
Parent
public XMLTokenizer.Type getType()
Node
public Element getRootElement()
public XMLDeclaration getXmlDeclaration()
public void setXmlDeclaration(XMLDeclaration xmlDeclaration)
public String getVersion()
protected XMLDeclaration createXMLDeclaration()
public String getEncoding()
public boolean isStandalone()
public void setStandalone(boolean standalone)
public Document toXML(XMLWriter writer) throws IOException
Node
toXML
in interface Node
toXML
in class NodeWithChildren
IOException
public void parseXMLDeclaration()
protected void clearXMLDeclaration()
public DocType getDocType()
public void setDocType(DocType docType)
public Namespaces getNamespaces()
public void setNamespaces(Namespaces namespaces)
public Document createClone()
Node
createClone
in interface Node
public Document copy(Node orig)
Node
orig
into this
copy
in interface Node
copy
in class NodeWithChildren
public Document copy()
Node
copy
in interface Node
copy
in class NodeWithChildren
public TreeIterator iterator()
Copyright © 2008–2021. All rights reserved.