Share via

IHTMLDocument2::all Property

Gets an interface pointer to a zero-based collection of all the elements in an HTML document.


HRESULT IHTMLDocument2::get_all(IHTMLElementCollection **p);


Return Value

Returns S_OK if successful, or an error value otherwise.


The collection includes one element object for each valid HTML tag. If a valid tag has a matching end tag, both tags are represented by the same element object. The collection always includes one element object for the html tag, the head tag, and the body tag, regardless of whether the tags are present in the document. If the document contains invalid or unknown tags, the collection includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own element objects. The order of the element objects in the collection is the same as the order of corresponding tags in the document. Although the collection indicates the order of tags, it does not indicate which tags contain others.

You can use the IHTMLElementCollection::length property to determine the number of element objects in the collection, and item or IHTMLElementCollection::tags to get individual objects or collections of objects from the collection. You can get individual objects by specifying the object's index or by using the object's name property. Index values can be numbers or names. Number values are zero-based, that is, zero for the first element object, one for the next element object, and so on. A name is valid only if it is defined by a name or IHTMLElement::id for at least one of the elements in the collection. If the name is defined by more than one element, you can use the name to get a collection of all element objects that define that name.

See Also

all, IHTMLDocument2::body