ddn.data.xml.dom.node

DOM node types and core parent/child ownership rules.

Types 12

Kind of an XmlNode.

DOCUMENTThe node is an XML document.
ELEMENTThe node is an element.
TEXTThe node is a text node.
ENTITY_REFERENCEThe node is an entity reference (e.g. `&name;`).
COMMENTThe node is a comment.
PROCESSING_INSTRUCTIONThe node is a processing instruction.
CDATAThe node is a CDATA section.
DOCUMENT_TYPEThe node is a document type declaration.
ENTITY_DECLARATIONThe node is an entity declaration.
NOTATION_DECLARATIONThe node is a notation declaration.
DOCUMENT_FRAGMENTThe node is a document fragment.
ATTRIBUTEThe node is an attribute.
classXmlNode

Base class for DOM nodes.

Ownership model: Each node has at most one parent. Parent nodes own their children.

Fields
private XmlNode _parent
XmlLocation locationLocation of this node in the source XML, if known.
string baseUriBase URI for this node.
XmlNodeType _nodeType
Methods
XmlNodeType nodeType() @property const @safe nothrowReturns the node kind.
string textContent() @property const @safeReturns the text content of this node and its descendants.
string nodeName() @property const @safeReturns the name of this node (W3C DOM Level 1).
string nodeValue() @property const @safeReturns the value of this node (W3C DOM Level 1).
void nodeValue(string value) @property @safeSets the value of this node (W3C DOM Level 1).
@property auto ownerDocument() @safeReturns the document object associated with this node.
string lexicalName() @property const @safeReturns the lexical name (e.g. "prefix:local") if applicable, or empty string.
bool hasAttributes() @property const @safeReturns `true` if this node has any attributes.
inout(XmlAttribute)[] attributes() @property inout @safeReturns the attributes of this node, or `null` if it is not an element.
inout(XmlNode)[] children() @property inout @safe nothrowReturns a list of all children of this node.
bool hasChildNodes() @property const @safe nothrowReturns `true` if this node has any children.
inout(XmlNode) parent() @property inout @safe nothrowReturns this node's parent, or `null` if it is detached.
string toString() const @safeReturns a string representation of this node for debugging.
string toDebugString() const @safeReturns a detailed string representation for debugging.
bool opEquals(Object o) const @safe
bool isEquivalent(const XmlNode other) const @safePerforms a deep logical comparison of two nodes.
Nullable!XmlNode nextSibling() @property @safeReturns the next sibling of this node.
Nullable!XmlNode previousSibling() @property @safeReturns the previous sibling of this node.
string effectiveBaseUri() const @safe nothrowReturns this node's effective base URI.
XmlNode cloneNode(bool deep = true) @safeCreates a copy of this node.
void detach() @safeDetaches this node from its parent.
void setParent(XmlNode parent) @safe
XmlNode cloneShallow() @safeCreates a shallow clone of this node (no children).
Constructors
this(XmlNodeType nodeType, XmlLocation location = XmlLocation.init)

Base class for nodes that can have children.

Fields
private XmlNode[] _children
Methods
bool isEquivalent(const XmlNode other) const @safe
inout(XmlNode)[] children() @property inout @safe nothrowReturns a list of all children of this node.
size_t length() @property const @safe nothrowReturns the number of child nodes.
bool empty() @property const @safe nothrowReturns `true` if there are no child nodes.
Nullable!XmlNode firstChild() @property @safeReturns the first child of this node.
Nullable!XmlNode lastChild() @property @safeReturns the last child of this node.
inout(XmlNode) opIndex(size_t index) inout @safeAllows accessing a child node by index.
size_t opDollar() const @safe nothrowAllows using `$` as the child count in index expressions.
inout(XmlNode)[] opSlice(size_t start, size_t end) inout @safeAllows slicing child nodes using `node[i .. j]` syntax.
string textContent() @property const @safe
XmlNode appendChild(XmlNode child) @safeAppends `child` at the end of this node's children.
XmlNode insertBefore(XmlNode newChild, XmlNode refChild) @safeInserts `newChild` before `refChild`.
XmlNode replaceChild(XmlNode newChild, XmlNode oldChild) @safeReplaces `oldChild` with `newChild`.
XmlNode removeChild(XmlNode child) @safeRemoves `child` from this node.
void insertChild(size_t index, XmlNode child) @safeInserts `child` at `index`.
void removeChildAt(size_t index) @safeRemoves the child at `index`.
void normalize(bool recurse = true) @safeNormalizes this subtree by merging adjacent `XmlText` nodes.
Constructors
this(XmlNodeType nodeType, XmlLocation location = XmlLocation.init)

A DOM document fragment node.

Methods
string nodeName() @property const @safe
Constructors
this(XmlLocation location = XmlLocation.init)

A DOM text node.

Fields
string textText content.
Methods
string nodeName() @property const @safe
string nodeValue() @property const @safe
void nodeValue(string val) @property @safe
string textContent() @property const @safe
string toString() const @safe
bool opEquals(Object o) const @safe
bool isEquivalent(const XmlNode other) const @safe
Constructors
this(string text, XmlLocation location = XmlLocation.init)

A DOM entity reference node.

This node represents an unresolved general entity reference in element content (e.g. &foo;). It is typically produced when parsing with entity expansion disabled.

Fields
string nameEntity name (without surrounding `&`/`;`).
Methods
string lexicalName() @property const @safe
Constructors
this(string name, XmlLocation location = XmlLocation.init)

A DOM comment node.

Fields
string textComment content (without `<!--` / `-->`).
Methods
string textContent() @property const @safe
string toString() const @safe
bool opEquals(Object o) const @safe
bool isEquivalent(const XmlNode other) const @safe
string nodeName() @property const @safe
string nodeValue() @property const @safe
void nodeValue(string val) @property @safe
Constructors
this(string text, XmlLocation location = XmlLocation.init)

A DOM processing-instruction node.

Fields
string targetTarget name.
string dataData content.
Methods
string textContent() @property const @safe
string lexicalName() @property const @safe
string nodeValue() @property const @safe
void nodeValue(string val) @property @safe
string toString() const @safe
bool opEquals(Object o) const @safe
bool isEquivalent(const XmlNode other) const @safe
Constructors
this(string target, string data, XmlLocation location = XmlLocation.init)

A DOM CDATA section node.

Fields
string textCDATA content.
Methods
string textContent() @property const @safe
string toString() const @safe
bool opEquals(Object o) const @safe
bool isEquivalent(const XmlNode other) const @safe
string nodeName() @property const @safe
string nodeValue() @property const @safe
void nodeValue(string val) @property @safe
Constructors
this(string text, XmlLocation location = XmlLocation.init)

A DOM document type declaration node.

Fields
string nameRoot element name (as declared in the doctype).
string publicIdPublic identifier.
string systemIdSystem identifier.
string internalSubsetInternal subset text (optional).
Methods
string lexicalName() @property const @safe
Constructors
this(string name, XmlLocation location = XmlLocation.init)

A DOM entity declaration node.

Fields
string nameEntity name.
string publicIdPublic identifier (for external entities).
string systemIdSystem identifier (for external entities).
string notationNameNotation name (for unparsed external entities).
string valueReplacement text (for internal entities).
bool isParameterWhether this is a parameter entity.
Methods
string lexicalName() @property const @safe
Constructors
this(string name, XmlLocation location = XmlLocation.init)

A DOM notation declaration node.

Fields
string nameNotation name.
string publicIdPublic identifier.
string systemIdSystem identifier.
Methods
string lexicalName() @property const @safe
Constructors
this(string name, XmlLocation location = XmlLocation.init)