PhoenixmlDb.Core

IXdmNode

Represents a node in the XQuery Data Model (XDM) tree — the parsed, structured representation of a stored XML or JSON document.

#IXdmNode

Namespace: PhoenixmlDb.Core

Represents a node in the XQuery Data Model (XDM) tree — the parsed, structured representation of a stored XML or JSON document.

The XDM is the data model defined by the W3C XQuery and XPath specifications. Every XML document is parsed into a tree of IXdmNode instances: a XdmNodeKind.Document node at the root, containing an XdmNodeKind.Element node for the root element, which in turn contains child elements, XdmNodeKind.Attribute nodes, XdmNodeKind.Text nodes, and so on.

The XDM tree is what the XQuery engine operates on internally. While most application code should use IContainer.QueryAsync to query documents with XQuery, IXdmNode is available for programmatic tree walking when you need to traverse the document structure in C# code.

Key properties:

  • IXdmNode.StringValue — the text content of the node. For elements, this is the concatenation of all descendant text nodes. For text nodes, it is the text itself.

  • IXdmNode.NodeName — the qualified name (QName) for elements, attributes, and processing instructions. Is null for document, text, and comment nodes.

#Example

Walk the XDM tree of a document:

csharp
var doc = await container.GetDocumentAsync("catalog.xml");
var root = await doc!.GetRootNodeAsync();

// root is the document node; its string value is all text content
Console.WriteLine($"Node kind: {root.NodeKind}");   // Document
Console.WriteLine($"Text content: {root.StringValue}");
                                  

#Properties

Name Description
Id Gets the database-assigned unique identifier for this node.
NodeKind Gets the kind of this node (document, element, attribute, text, comment, etc.).
NodeName Gets the qualified name of this node, or null for node kinds that do not have names.
Parent Gets the parent node, or null if this is the root document node.
StringValue Gets the string value of this node, as defined by the XDM specification.

#See also