PhoenixmlDb.Core

XmlSerializer

Serializes XDM node trees back to XML text, completing the round-trip from (parse) to in-memory XDM to XML output.

#XmlSerializer

Namespace: PhoenixmlDb.Xdm.Parsing

Serializes XDM node trees back to XML text, completing the round-trip from (parse) to in-memory XDM to XML output.

Round-trip fidelity: The serializer preserves namespace prefixes, attribute order, and namespace declarations from the original parse. Combined with , this enables a parse-modify-serialize workflow where the output closely matches the input (modulo XML declaration differences and whitespace normalization). Namespace handling: Namespace URIs are stored as interned values in XDM nodes. The serializer uses the provided namespaceResolver function to convert them back to URI strings, and writes namespace declarations based on each element's . Node resolution: Since XDM nodes reference their children by , the serializer requires a nodeResolver function to look up child nodes. This is typically provided by the storage layer.

#Constructors

##ctor(Func<PhoenixmlDb.Core.NodeId,PhoenixmlDb.Xdm.Nodes.XdmNode>,Func<PhoenixmlDb.Core.NamespaceId,String>,Boolean)

Creates a new XML serializer with the specified resolution functions.

Parameters:

  • nodeResolver — Function to resolve references to instances. Returns null if the node is not found (which causes it to be silently skipped).

  • namespaceResolver — Function to resolve values back to namespace URI strings. Returns null if the namespace is not found (treated as no namespace).

  • indent — When true (the default), the output XML is indented for readability. Pass false for compact output.

#Methods

#Serialize(PhoenixmlDb.Xdm.Nodes.XdmDocument,IO.TextWriter)

Serializes a complete to a , for streaming output without buffering the entire XML string in memory.

Parameters:

  • document — The document node to serialize.

  • textWriter — The writer to receive the XML output.

#Serialize(PhoenixmlDb.Xdm.Nodes.XdmDocument)

Serializes a complete to an XML string, including the XML declaration.

Parameters:

  • document — The document node to serialize.

Returns: The XML string representation of the document.

#Serialize(PhoenixmlDb.Xdm.Nodes.XdmNode)

Serializes a single (and its subtree) to an XML string fragment.

Parameters:

  • node — The node to serialize. If this is an element, its entire subtree is included.

Returns: The XML string representation of the node.