Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

nodeFromID Method

Returns the node that matches the ID attribute.

[Script]

Script Syntax

var objXMLDOMNode = oXMLDOMDocument.nodeFromID(idString);

Parameters

idString
The string containing the value of the ID to match.

Return Value

An object. Returns the node that matches the supplied ID. If no nodes match, returns Null.

[Visual Basic]

Visual Basic Syntax

Set objXMLDOMNode = oXMLDOMDocument.nodeFromID(idString)

Parameters

idString
The string containing the value of the ID to match.

Return Value

An object. Returns the node that matches the supplied ID. If no nodes match, returns Null.

[C/C++]

C/C++ Syntax

HRESULT nodeFromID(
    BSTR idString,
    IXMLDOMNode **node);

Parameters

idString [in]
The value of the ID to match.
node [out, retval]
The node that matches the supplied ID. If no nodes match, this method returns Null.

C/C++ Return Values

S_OK
The value returned if successful.
S_FALSE
The value returned when there is no node with the given ID.
E_INVALIDARG
The value returned if the node parameter is Null.

Remarks

According to the XML 1.0 Recommendation (REC-xml-19980210), ID attribute values must be unique within their XML documents and no element can specify more than one ID attribute.

The nodeFromID method was designed to handle ID and IDREF relationships in XML, but does not require an attribute of type IDREF. It can be used generically, and is similar to the all collection in DHTML.

To reference a node with nodefromID, the node must be typed as ID in the schema or document type definition (DTD). Simply naming an attribute "ID" does not set its data type.

This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Applies to: DOMDocument