firstChild Property
Contains the first child of the node.
[Script]
Script Syntax
var objXMLDOMNode = oXMLDOMNode.firstChild;
Example
The following example sets currNode to the first child node of the top-level node.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var currNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
currNode = xmlDoc.documentElement.firstChild;
alert(currNode.xml);
[Visual Basic]
Visual Basic Syntax
Set objXMLDOMNode = oXMLDOMNode.firstChild
Example
The following example sets currNode to the first child node of the top-level node.
Dim xmlDoc As New Msxml2.DOMDocument40
Dim currNode As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set currNode = xmlDoc.documentElement.firstChild
MsgBox currNode.xml
[C/C++]
C/C++ Syntax
HRESULT get_firstChild(
IXMLDOMNode **firstChild);
Parameters
- firstChild [out, retval]
- The first child node. If there are no such children, it returns Null.
C/C++ Return Values
- S_OK
- The value returned if successful.
- S_FALSE
- The value returned when there are no children.
- E_INVALIDARG
- The value returned if firstChild is Null.
Remarks
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. |
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
See Also
nodeType Property
Applies to: IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment |DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText