Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

firstChild Property

 

Contains the first child of the node.

var objXMLDOMNode = oXMLDOMNode.firstChild;

The following example sets currNode to the first child node of the top-level node.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   currNode = xmlDoc.documentElement.firstChild;
   WScript.Echo(currNode.xml);
}

Set objXMLDOMNode = oXMLDOMNode.firstChild

HRESULT get_firstChild(
    IXMLDOMNode **firstChild);

 firstChild[out, retval]

The first child node. If there are no such children, it returns Null.

S_OK

The value returned if successful.

S_FALSE

The value returned when there are no children.

E_INVALIDARG

The value returned if the firstChild parameter is Null.

The property is read-only. Returns the first child node. If there are no such children, returns Null.

This value depends on the value of the nodeType property.

NODE_ATTRIBUTE

NODE_DOCUMENT

NODE_DOCUMENT_FRAGMENT

NODE_DOCUMENT_TYPE

NODE_ELEMENT

NODE_ENTITY

NODE_ENTITY_REFERENCE

Returns the first child node. If there are no children, returns Null.

NODE_CDATA_SECTION

NODE_COMMENT

NODE_NOTATION

NODE_PROCESSING_INSTRUCTION

NODE_TEXT

Returns Null. These node types cannot have children.

Implemented in:

MSXML 3.0, MSXML 6.0

Show:
© 2016 Microsoft