parentNode Property1


Contains the parent node.

var objXMLDOMNode = oXMLDOMNode.parentNode;  


The following script example sets a variable ('newNode') to reference the parent node of another IXMLDOMNode object ('currNode'). It then uses the reference to the new node to display the XML contents of its parent node.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
var newNode;
xmlDoc.async = false;
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   currNode =    xmlDoc.documentElement.childNodes.item(1).childNodes.item(0);
   newNode = currNode.parentNode;

Set objXMLDOMNode = oXMLDOMNode.parentNode  

HRESULT get_parentNode(  
    IXMLDOMNode **parent);  


parent[out, retval]
The parent of the given node instance.

C/C++ Return Values

The value returned if there is no parent.

The value returned if successful.

The value returned if the parent parameter is Null.

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.



Returns Null; these nodes do not have parents.
NODE_CDATA_SECTIONReturns the element or entity reference containing the CDATA section.
NODE_COMMENTReturns the element, entity reference, document type, or document containing the comment.
NODE_DOCUMENT_TYPEReturns the document node.
NODE_ELEMENTReturns 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_ENTITYReturns the document type node.
NODE_ENTITY_REFERENCEReturns the element, attribute, or entity reference containing the entity reference.
NODE_NOTATIONReturns the document type node.
NODE_PROCESSING_INSTRUCTIONReturns the document, element, document type, or entity reference containing the processing instruction.
NODE_TEXTReturns the parent element, attribute, or entity reference.

Implemented in:

MSXML 3.0, MSXML 6.0

IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMDocument-DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText

nodeType Property1