XmlDocumentFragment XmlDocumentFragment XmlDocumentFragment XmlDocumentFragment Class

Represents a lightweight object that is useful for tree insertion operations.

Syntax

Declaration

public sealed class XmlDocumentFragmentpublic sealed class XmlDocumentFragmentPublic NotInheritable Class XmlDocumentFragmentpublic sealed class XmlDocumentFragment

Properties summary

Gets the list of attributes of this node.

Gets a list of children in the current node.

Gets the first child node.

Gets the text from inside the XML.

Gets the last child node.

Gets the local name, which is the local part of a qualified name. This is called the local part in Namespaces in XML.

Returns the Uniform Resource Identifier (URI) for the namespace.

Gets the next sibling of the node in the parent's child list.

Returns the qualified name for attribute, document type, element, entity, or notation nodes. Returns a fixed string for all other node types.

Gets the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes.

Gets or sets the text associated with the node.

Returns the root of the document that contains the node.

Gets the parent node of the node instance. This property is not applicable to this class.

Gets or sets the namespace prefix.

Gets the previous sibling of the node in the parent's child list. This property is not applicable to this class.

Methods summary

Appends a new child node as the last child of the node.

Clones a new node.

Returns the XML representation of the node and all its descendants.

Determines whether a node has children.

Inserts a child node to the left of the specified node, or at the end of the list.

Normalizes all descendant elements by combining two or more adjacent text nodes into one unified text node.

Removes the specified child node from the list of children and returns it.

Replaces the specified old child node with the supplied new child node.

Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.

Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.

Applies the specified pattern-matching operation to this node's context and returns the first matching node.

Applies the specified pattern-matching operation to this node's context and returns the first matching node.

Properties

  • Attributes
    Attributes
    Attributes
    Attributes

    Gets the list of attributes of this node.

    public XmlNamedNodeMap Attributes { get; }public XmlNamedNodeMap Attributes { get; }Public ReadOnly Property Attributes As XmlNamedNodeMappublic XmlNamedNodeMap Attributes { get; }

    Property Value

    Remarks

    This property returns a XmlNamedNodeMap for the nodes that can return attributes. These are the Element, Entity, and Notation nodes. This property is NULL for all other node types. For the valid node types, the XmlNamedNodeMap is always returned; when there are no attributes on the element, the list length is set to zero.

    The following table describes the attributes for the node types.

    NodeTypeAttributes
    ElementIXmlNamedNodeMap
    AttributeNULL
    TextNULL
    CDATASectionNULL
    EntityReferenceNULL
    EntityNULL
    ProcessingInstructionNULL
    CommentNULL
    DocumentNULL
    DocumentTypeNULL
    DocumentFragmentNULL
    NotationNULL
  • ChildNodes
    ChildNodes
    ChildNodes
    ChildNodes

    Gets a list of children in the current node.

    public XmlNodeList ChildNodes { get; }public XmlNodeList ChildNodes { get; }Public ReadOnly Property ChildNodes As XmlNodeListpublic XmlNodeList ChildNodes { get; }

    Property Value

  • FirstChild
    FirstChild
    FirstChild
    FirstChild

    Gets the first child node.

    public IXmlNode FirstChild { get; }public IXmlNode FirstChild { get; }Public ReadOnly Property FirstChild As IXmlNodepublic IXmlNode FirstChild { get; }

    Property Value

  • InnerText
    InnerText
    InnerText
    InnerText

    Gets the text from inside the XML.

    public string InnerText { get; set; }public string InnerText { get; set; }Public ReadWrite Property InnerText As stringpublic string InnerText { get; set; }

    Property Value

    • string
      string
      string
      string

      The text from inside the XML. Returns an empty string if there is no text.

  • LastChild
    LastChild
    LastChild
    LastChild

    Gets the last child node.

    public IXmlNode LastChild { get; }public IXmlNode LastChild { get; }Public ReadOnly Property LastChild As IXmlNodepublic IXmlNode LastChild { get; }

    Property Value

  • LocalName
    LocalName
    LocalName
    LocalName

    Gets the local name, which is the local part of a qualified name. This is called the local part in Namespaces in XML.

    public object LocalName { get; }public object LocalName { get; }Public ReadOnly Property LocalName As objectpublic object LocalName { get; }

    Property Value

    • object
      object
      object
      object

      The local name.

  • NamespaceUri
    NamespaceUri
    NamespaceUri
    NamespaceUri

    Returns the Uniform Resource Identifier (URI) for the namespace.

    public object NamespaceUri { get; }public object NamespaceUri { get; }Public ReadOnly Property NamespaceUri As objectpublic object NamespaceUri { get; }

    Property Value

    • object
      object
      object
      object

      The Uri for the namespace. This refers to the "uuu" portion of the namespace declaration xmlns:nnn="uuu".

  • NextSibling
    NextSibling
    NextSibling
    NextSibling

    Gets the next sibling of the node in the parent's child list.

    public IXmlNode NextSibling { get; }public IXmlNode NextSibling { get; }Public ReadOnly Property NextSibling As IXmlNodepublic IXmlNode NextSibling { get; }

    Property Value

  • NodeName
    NodeName
    NodeName
    NodeName

    Returns the qualified name for attribute, document type, element, entity, or notation nodes. Returns a fixed string for all other node types.

    public string NodeName { get; }public string NodeName { get; }Public ReadOnly Property NodeName As stringpublic string NodeName { get; }

    Property Value

    • string
      string
      string
      string

      The qualified node name, which varies depending on the node type.

    Remarks

    This value depends on the NodeType property. The following table describes this dependency.

    NodeTypeNodeName
    ElementtagName
    Attributename of attribute
    Text#text
    CDATASection#cdata-section
    EntityReferencename of entity referenced
    Entityentity name
    ProcessingInstructiontarget
    Comment#comment
    Document#document
    DocumentTypedocument type name
    DocumentFragment#document-fragment
    Notationnotation name
  • NodeType
    NodeType
    NodeType
    NodeType

    Gets the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes.

    public NodeType NodeType { get; }public NodeType NodeType { get; }Public ReadOnly Property NodeType As NodeTypepublic NodeType NodeType { get; }

    Property Value

  • NodeValue
    NodeValue
    NodeValue
    NodeValue

    Gets or sets the text associated with the node.

    public object NodeValue { get; set; }public object NodeValue { get; set; }Public ReadWrite Property NodeValue As objectpublic object NodeValue { get; set; }

    Property Value

    • object
      object
      object
      object

      The text associated with the node.

    Remarks

    This value depends on the NodeType property. The following table describes this dependency.

    NodeTypeNodeValue
    ElementNull
    AttributeValue of attribute
    TextContent of the text node
    CDATASectionContent of the CDATA Section
    EntityReferenceNULL
    EntityNULL
    ProcessingInstructionEntire content excluding the target
    CommentContent of the comment
    DocumentNULL
    DocumentTypeNULL
    DocumentFragmentNULL
    NotationNULL
  • OwnerDocument
    OwnerDocument
    OwnerDocument
    OwnerDocument

    Returns the root of the document that contains the node.

    public XmlDocument OwnerDocument { get; }public XmlDocument OwnerDocument { get; }Public ReadOnly Property OwnerDocument As XmlDocumentpublic XmlDocument OwnerDocument { get; }

    Property Value

  • ParentNode
    ParentNode
    ParentNode
    ParentNode

    Gets the parent node of the node instance. This property is not applicable to this class.

    public IXmlNode ParentNode { get; }public IXmlNode ParentNode { get; }Public ReadOnly Property ParentNode As IXmlNodepublic IXmlNode ParentNode { get; }

    Property Value

  • Prefix
    Prefix
    Prefix
    Prefix

    Gets or sets the namespace prefix.

    public object Prefix { get; set; }public object Prefix { get; set; }Public ReadWrite Property Prefix As objectpublic object Prefix { get; set; }

    Property Value

    • object
      object
      object
      object

      The namespace prefix specified on the element, attribute, or entity reference. For example, for the element <xxx:yyy>, this property returns xxx. It returns an empty string, "", if no prefix is specified.

  • PreviousSibling
    PreviousSibling
    PreviousSibling
    PreviousSibling

    Gets the previous sibling of the node in the parent's child list. This property is not applicable to this class.

    public IXmlNode PreviousSibling { get; }public IXmlNode PreviousSibling { get; }Public ReadOnly Property PreviousSibling As IXmlNodepublic IXmlNode PreviousSibling { get; }

    Property Value

Methods

  • AppendChild(IXmlNode)
    AppendChild(IXmlNode)
    AppendChild(IXmlNode)
    AppendChild(IXmlNode)

    Appends a new child node as the last child of the node.

    public IXmlNode AppendChild(IXmlNode newChild)public IXmlNode AppendChild(IXmlNode newChild)Public Function AppendChild(newChild As IXmlNode) As IXmlNodepublic IXmlNode AppendChild(IXmlNode newChild)

    Parameters

    Returns

  • CloneNode(Boolean)
    CloneNode(Boolean)
    CloneNode(Boolean)
    CloneNode(Boolean)

    Clones a new node.

    public IXmlNode CloneNode(Boolean deep)public IXmlNode CloneNode(Boolean deep)Public Function CloneNode(deep As Boolean) As IXmlNodepublic IXmlNode CloneNode(Boolean deep)

    Parameters

    • deep
      System.Boolean
      System.Boolean
      System.Boolean
      System.Boolean

      A flag that indicates whether to recursively clone all nodes that are descendants of this node. If true, this method creates a clone of the complete tree below this node. If false, this method clones this node and its attributes only.

    Returns

  • GetXml()
    GetXml()
    GetXml()
    GetXml()

    Returns the XML representation of the node and all its descendants.

    public string GetXml()public string GetXml()Public Function GetXml() As stringpublic string GetXml()

    Returns

    • string
      string
      string
      string

      The XML representation of the node and all its descendants.

  • HasChildNodes()
    HasChildNodes()
    HasChildNodes()
    HasChildNodes()

    Determines whether a node has children.

    public bool HasChildNodes()public bool HasChildNodes()Public Function HasChildNodes() As boolpublic bool HasChildNodes()

    Returns

    • bool
      bool
      bool
      bool

      True if this node has children; otherwise false.

  • InsertBefore(IXmlNode, IXmlNode)
    InsertBefore(IXmlNode, IXmlNode)
    InsertBefore(IXmlNode, IXmlNode)
    InsertBefore(IXmlNode, IXmlNode)

    Inserts a child node to the left of the specified node, or at the end of the list.

    public IXmlNode InsertBefore(IXmlNode newChild, IXmlNode referenceChild)public IXmlNode InsertBefore(IXmlNode newChild, IXmlNode referenceChild)Public Function InsertBefore(newChild As IXmlNode, referenceChild As IXmlNode) As IXmlNodepublic IXmlNode InsertBefore(IXmlNode newChild, IXmlNode referenceChild)

    Parameters

    • newChild

      The address of the new node to be inserted. The node passed here must be a valid child of the current XML DOM document node. For example, if the current node is an attribute, you cannot pass another attribute in the newChild parameter, because an attribute cannot have an attribute as a child. If newChild is a DOCUMENT_FRAGMENT node type, all its children are inserted in order before referenceChild.

      If newChild is already in the tree, it is first removed before it is reinserted before the referenceChild node. Read-only nodes, such as NODE_DOCUMENT_TYPE and NODE_ENTITY nodes, cannot be passed in the newChild parameter.

    • referenceChild

      The reference node. The node specified is where the newChild node is to be inserted to the left as the preceding sibling in the child list. The node passed here must be a either a child node of the current node or null. If the value is null, the newChild node is inserted at the end of the child list. If the referenceChild node is not a child of the current node, an error is returned.

    Returns

  • Normalize()
    Normalize()
    Normalize()
    Normalize()

    Normalizes all descendant elements by combining two or more adjacent text nodes into one unified text node.

    public void Normalize()public void Normalize()Public Function Normalize() As voidpublic void Normalize()
  • RemoveChild(IXmlNode)
    RemoveChild(IXmlNode)
    RemoveChild(IXmlNode)
    RemoveChild(IXmlNode)

    Removes the specified child node from the list of children and returns it.

    public IXmlNode RemoveChild(IXmlNode childNode)public IXmlNode RemoveChild(IXmlNode childNode)Public Function RemoveChild(childNode As IXmlNode) As IXmlNodepublic IXmlNode RemoveChild(IXmlNode childNode)

    Parameters

    Returns

  • ReplaceChild(IXmlNode, IXmlNode)
    ReplaceChild(IXmlNode, IXmlNode)
    ReplaceChild(IXmlNode, IXmlNode)
    ReplaceChild(IXmlNode, IXmlNode)

    Replaces the specified old child node with the supplied new child node.

    public IXmlNode ReplaceChild(IXmlNode newChild, IXmlNode referenceChild)public IXmlNode ReplaceChild(IXmlNode newChild, IXmlNode referenceChild)Public Function ReplaceChild(newChild As IXmlNode, referenceChild As IXmlNode) As IXmlNodepublic IXmlNode ReplaceChild(IXmlNode newChild, IXmlNode referenceChild)

    Parameters

    Returns

  • SelectNodes(String)
    SelectNodes(String)
    SelectNodes(String)
    SelectNodes(String)

    Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.

    public XmlNodeList SelectNodes(String xpath)public XmlNodeList SelectNodes(String xpath)Public Function SelectNodes(xpath As String) As XmlNodeListpublic XmlNodeList SelectNodes(String xpath)

    Parameters

    • xpath
      System.String
      System.String
      System.String
      System.String

      Specifies an XPath expression.

    Returns

  • SelectNodesNS(String, Object)
    SelectNodesNS(String, Object)
    SelectNodesNS(String, Object)
    SelectNodesNS(String, Object)

    Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.

    public XmlNodeList SelectNodesNS(String xpath, Object namespaces)public XmlNodeList SelectNodesNS(String xpath, Object namespaces)Public Function SelectNodesNS(xpath As String, namespaces As Object) As XmlNodeListpublic XmlNodeList SelectNodesNS(String xpath, Object namespaces)

    Parameters

    • xpath
      System.String
      System.String
      System.String
      System.String

      Specifies an XPath expression.

    • namespaces
      System.Object
      System.Object
      System.Object
      System.Object

      Contains a string that specifies namespaces for use in XPath expressions when it is necessary to define new namespaces externally. Namespaces are defined in the XML style, as a space-separated list of namespace declaration attributes. You can use this property to set the default namespace as well.

    Returns

    Remarks

    Prefixes in the query are resolved using the specified namespace declarations.

  • SelectSingleNode(String)
    SelectSingleNode(String)
    SelectSingleNode(String)
    SelectSingleNode(String)

    Applies the specified pattern-matching operation to this node's context and returns the first matching node.

    public IXmlNode SelectSingleNode(String xpath)public IXmlNode SelectSingleNode(String xpath)Public Function SelectSingleNode(xpath As String) As IXmlNodepublic IXmlNode SelectSingleNode(String xpath)

    Parameters

    • xpath
      System.String
      System.String
      System.String
      System.String

      Specifies an XPath expression.

    Returns

    • The first node that matches the given pattern-matching operation. If no nodes match the expression, the method returns a null value.

  • SelectSingleNodeNS(String, Object)
    SelectSingleNodeNS(String, Object)
    SelectSingleNodeNS(String, Object)
    SelectSingleNodeNS(String, Object)

    Applies the specified pattern-matching operation to this node's context and returns the first matching node.

    public IXmlNode SelectSingleNodeNS(String xpath, Object namespaces)public IXmlNode SelectSingleNodeNS(String xpath, Object namespaces)Public Function SelectSingleNodeNS(xpath As String, namespaces As Object) As IXmlNodepublic IXmlNode SelectSingleNodeNS(String xpath, Object namespaces)

    Parameters

    • xpath
      System.String
      System.String
      System.String
      System.String

      Specifies an XPath expression.

    • namespaces
      System.Object
      System.Object
      System.Object
      System.Object

      Contains a string that specifies the namespaces to use in XPath expressions when it is necessary to define new namespaces externally. Namespaces are defined in the XML style, as a space-separated list of namespace declaration attributes. You can use this property to set the default namespace as well.

    Returns

    • The first node that matches the given pattern-matching operation. If no nodes match the expression, this method returns a null value.

    Remarks

    Prefixes in the query are resolved using the specified namespace declarations.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.Data.Xml.Dom.dll