Contains the parent node (for nodes that can have parents).
Syntax
objXMLDOMNode = oXMLDOMNode.parentNode
Remarks
Object. The property is read-only. All nodes, except Document, DocumentFragment, and Attribute nodes, can have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is null.
This value depends on the value of the nodeType property.
NODE_ATTRIBUTE, NODE_DOCUMENT, NODE_DOCUMENT_FRAGMENT | Returns null; these nodes do not have parents. |
NODE_CDATA_SECTION | Returns the element or entity reference containing the CDATA section. |
NODE_COMMENT | Returns the element, entity reference, document type, or document containing the comment. |
NODE_DOCUMENT_TYPE | Returns the document node. |
NODE_ELEMENT | Returns the parent node of the element. If the element is the root node in the tree, the parent is the document node. If the node is the document node, parentNode is null. |
NODE_ENTITY | Returns the document type node. |
NODE_ENTITY_REFERENCE | Returns the element, attribute, or entity reference containing the entity reference. |
NODE_NOTATION | Returns the document type node. |
NODE_PROCESSING_INSTRUCTION | Returns the document, element, document type, or entity reference containing the processing instruction. |
NODE_TEXT | Returns the parent element, attribute, or entity reference. |
Example
The following VBScript example creates an XMLDOMNode object from another node object's parent, and displays its XML:
Dim xmlDoc
Dim currNode
Dim newNode
Set xmlDoc = CreateObject("microsoft.xmldom")
xmlDoc.async = False
xmlDoc.load("c:\books.xml")
Set currNode = xmlDoc.documentElement.childNodes.item(1).childNodes.item(0)
Set newNode = currNode.parentNode
MsgBox newNode.xml
Applies To
XMLDOMAttribute, XMLDOMCDATASection, XMLDOMCharacterData, XMLDOMComment, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMEntity, XMLDOMEntityReference, XMLDOMNode, XMLDOMNotation, XMLDOMProcessingInstruction, XMLDOMText, XTLRuntime