# XmlDocument data type
> Version: _Available or changed with runtime version 1.0._
Represents an XML document.
## Static methods
The following methods are available on the XmlDocument data type.
Method name|Description
xmldocument-create--method|Creates an XmlDocument.
Create(Any,...)<xmldocument-create-joker-method>|Creates an XmlDocument.
ReadFrom(Text, var XmlDocument)<xmldocument-readfrom-string-xmldocument-method>|Reads and parses the XML document from the given data source.
ReadFrom(Text, XmlReadOptions, var XmlDocument)<xmldocument-readfrom-string-xmlreadoptions-xmldocument-method>|Reads and parses the XML document from the given data source.
ReadFrom(InStream, var XmlDocument)<xmldocument-readfrom-instream-xmldocument-method>|Reads and parses the XML document from the given data source.
ReadFrom(InStream, XmlReadOptions, var XmlDocument)<xmldocument-readfrom-instream-xmlreadoptions-xmldocument-method>|Reads and parses the XML document from the given data source.
## Instance methods
The following methods are available on instances of the XmlDocument data type.
Method name|Description
Add(Any,...)<xmldocument-add-method>|Adds the specified content as a child of this document.
AddAfterSelf(Any,...)<xmldocument-addafterself-method>|Adds the specified content immediately after this node.
AddBeforeSelf(Any,...)<xmldocument-addbeforeself-method>|Adds the specified content immediately before this node.
AddFirst(Any,...)<xmldocument-addfirst-method>|Adds the specified content at the start of the child list of this document.
xmldocument-asxmlnode-method|Converts the node to an XmlNode.
xmldocument-getchildelements--method|Gets a list containing the child elements for this document, in document order.
GetChildElements(Text)<xmldocument-getchildelements-string-method>|Gets a list containing the child elements for this document, in document order.
GetChildElements(Text, Text)<xmldocument-getchildelements-string-string-method>|Gets a list containing the child elements for this document, in document order.
xmldocument-getchildnodes-method|Gets a list containing the child elements for this document, in document order.
GetDeclaration(var XmlDeclaration)<xmldocument-getdeclaration-method>|Gets the XML declaration for this document.
xmldocument-getdescendantelements--method|Gets a list containing the descendant elements for this document, in document order.
GetDescendantElements(Text)<xmldocument-getdescendantelements-string-method>|Gets a list containing the descendant elements for this document, in document order.
GetDescendantElements(Text, Text)<xmldocument-getdescendantelements-string-string-method>|Gets a list containing the descendant elements for this document, in document order.
xmldocument-getdescendantnodes-method|Gets a list containing the descendant nodes for this document, in document order.
GetDocument(var XmlDocument)<xmldocument-getdocument-method>|Gets the XmlDocument for this node.
GetDocumentType(var XmlDocumentType)<xmldocument-getdocumenttype-method>|Gets the Document Type Definition (DTD) for this document.
GetParent(var XmlElement)<xmldocument-getparent-method>|Gets the parent XmlElement of this node.
GetRoot(var XmlElement)<xmldocument-getroot-method>|Gets the root element of the XML tree for this document.
xmldocument-nametable-method|Gets the XmlNameTable associated with this document.
xmldocument-remove-method|Removes this node from its parent element.
xmldocument-removenodes-method|Removes the child nodes from this document.
ReplaceNodes(Any,...)<xmldocument-replacenodes-method>|Replaces the children nodes of this document with the specified content.
ReplaceWith(Any,...)<xmldocument-replacewith-method>|Replaces this node with the specified content.
SelectNodes(Text, var XmlNodeList)<xmldocument-selectnodes-string-xmlnodelist-method>|Selects a list of nodes matching the XPath expression.
SelectNodes(Text, XmlNamespaceManager, var XmlNodeList)<xmldocument-selectnodes-string-xmlnamespacemanager-xmlnodelist-method>|Selects a list of nodes matching the XPath expression.
SelectSingleNode(Text, var XmlNode)<xmldocument-selectsinglenode-string-xmlnode-method>|Selects the first XmlNode that matches the XPath expression.
SelectSingleNode(Text, XmlNamespaceManager, var XmlNode)<xmldocument-selectsinglenode-string-xmlnamespacemanager-xmlnode-method>|Selects the first XmlNode that matches the XPath expression.
SetDeclaration(XmlDeclaration)<xmldocument-setdeclaration-method>|Sets the XML declaration for this document.
xmldocument-writeto-outstream-method|Serializes and saves the current node to the given variable.
xmldocument-writeto-xmlwriteoptions-outstream-method|Serializes and saves the current node to the given variable.
WriteTo(var Text)<xmldocument-writeto-text-method>|Serializes and saves the current node to the given variable.
WriteTo(XmlWriteOptions, var Text)<xmldocument-writeto-xmlwriteoptions-text-method>|Serializes and saves the current node to the given variable.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/xmldocument/xmldocument-data-type, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/xmldocument/xmldocument-data-type/
