- pif:Pointer to the IHTMLViewModel interface object. nElem The location of the element in the document. This can be obtained from IHTMLVIEWMODEL_FindElem(). pchBuf Pointer to the start of a buffer to hold the result (which is a zero-terminated string) cbBuf Size of the buffer, in bytes
int32 IHTMLViewModel_GetElemText(IHTMLViewModel *pif, int32 nElem, char *pchBuf, int32 cbBuf);
HVM_BADELEMENT, if failure. This occurs only when the nElemPos value is invalid. Length of the resulting string, if successful. 0(zero), if an empty element, or an element that contains no text is present. A value larger than cbBuf may be returned, but only cbBuf bytes are written to the buffer in that case.
The text that we are getting from IHTMLVIEWMODEL_GetElemText() is the text between the opening and closing tag such as in links, titles, etc. For example: Link Text Please note that IHTMLVIEWMODEL_GetElemText cannot be used to retrieve the text of the text input control. The text input control is not a container, so the end tag is forbidden. In order to retrieve it's default text IHTMLVIEWMODEL_GetAttrValue() should be used.