CustomXMLNode Object (Office)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents an XML node in a tree in a document. The CustomXMLNode object is a member of the CustomXMLNodes collection.

The CustomXMLNode object is designed to have functional parity with the IXMLDOMNode interface. In addition, it contains an XPath property, which is a great improvement over the objects provided by MSXML.

The following example selects a single node from a CustomXMLPart object by using an XPath expression and assigns it to a CustomXMLNode object.

Sub CustomXmlNodes()  
    Dim cxp1 As CustomXMLPart 
    Dim cxn As CustomXMLNode 
 
    With ActiveDocument 
 
        ' Returns the first custom xml part with the given root namespace. 
        Set cxp1 = .CustomXMLParts("urn:invoice:namespace")  
         
        ' Get the first node matching the XPath expression.                              
        Set cxn = cxp1.SelectSingleNode("//*[@quantity < 4]") 
                 
    End With 
     
End Sub

Name

Description

AppendChildNode

Appends a single node as the last child under the context element node in the tree.

AppendChildSubtree

Adds a subtree as the last child under the context element node in the tree.

Delete

Deletes the current node from the tree (including all of its children, if any exist).

HasChildNodes

Gets True if the current element node has child element nodes.

InsertNodeBefore

Inserts a new node just before the context node in the tree.

InsertSubtreeBefore

Inserts the specified subtree into the location just before the context node.

RemoveChild

Removes the specified child node from the tree.

ReplaceChildNode

Removes the specified child node (and its subtree) from the main tree, and replaces it with a different node in the same location.

ReplaceChildSubtree

Removes the specified node (and its subtree) from the main tree, and replaces it with a different subtree in the same location.

SelectNodes

Selects a collection of nodes matching an XPath expression. This method differs from the CustomXMLPart.SelectNodes method in that the XPath expression will be evaluated starting with the 'expression' node as the context node.

SelectSingleNode

Selects a single node from a collection matching an XPath expression. This method differs from the CustomXMLPart.SelectSingleNode method in that the XPath expression will be evaluated starting with the 'expression' node as the context node.

Show: