Contains the element name, the name that appears within the tag.
Visual Basic Syntax
strValue = oXMLDOMElement.tagName
C/C++ Syntax
HRESULT get_tagName(
BSTR *tagName);
Parameters
tagName
[out]
String that represents the element's name. For example, the tag name is "book" in the following tag:
<book ISBN="1572318546">
C/C++ Return Values
S_OK
Value returned if successful.
S_FALSE
Value when returning null.
E_INVALIDARG
Value returned if tagName is null.
C/C++ Example
IXMLDOMElement *pIXMLDOMElement = NULL;
BSTR bstrTagName = NULL;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
HRESULT hr;
try
{
// create an instance of DOMDocument and initialize pIXMLDOMDocument
// load/create an XML fragment
hr = pIXMLDOMDocument->get_documentElement(&pIXMLDOMElement);
SUCCEEDED(hr) ? 0 : throw hr;
if(pIXMLDOMElement)
{
hr = pIXMLDOMElement->get_tagName(&bstrTagName);
if(SUCCEEDED(hr))
{
::MessageBox(NULL, bstrTagName, _T("Tag Name"), MB_OK);
}
::SysFreeString(bstrTagName);
bstrTagName = NULL;
pIXMLDOMElement->Release();
}
}
catch(...)
{
if(bstrTagName)
::SysFreeString(bstrTagName);
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}