PhoenixmlDb.Core
XdmDocument
Represents an XML document root node in the XDM tree.
#XdmDocument
Namespace: PhoenixmlDb.Xdm.Nodes
Represents an XML document root node in the XDM tree.
The document node is the root of every XDM document tree. Per the XDM specification, a document node's children can only be element, comment, and processing instruction nodes — text nodes at the document level are not permitted. Typically, a well-formed XML document has exactly one element child (the document element), plus optional comments and PIs.
Document URI: The XdmDocument.DocumentUri identifies the document and is used by functions like fn:document-uri() and fn:doc(). For documents loaded from the database, this is typically the storage URI; for parsed strings, it can be explicitly set.
Base URI: The document node's XdmNode.BaseUri defaults to the XdmDocument.DocumentUri when not explicitly set, providing the root base URI from which all descendant nodes inherit.
#Example
Accessing the document element:
XdmDocument doc = parseResult.Document;
if (doc.DocumentElement is NodeId elemId)
{
var rootElement = (XdmElement)resolveNode(elemId);
Console.WriteLine($"Root element: {rootElement.LocalName}");
}
#Properties
| Name | Description |
|---|---|
Children
|
The NodeId references to this document's child nodes in document order.
|
DocumentElement
|
The NodeId of the document element (the first element child), or null if the document has no element children.
|
DocumentElementLocalName
|
The local name of the document element, cached for efficient document-node(element(name)) type checks in XPath/XQuery.
|
DocumentUri
|
The document URI (dm:document-uri), which uniquely identifies this document.
|
EmptyChildren
|
An empty, immutable children list for documents with no child nodes. |
StringValue
|
The string value of this document, which is the concatenation of all descendant text nodes. |
#Fields
| Name | Description |
|---|---|
_stringValue
|
Internal backing field for the lazily-computed string value. Set by tree walkers after traversing descendant text nodes. |