Contains the element name.
strValue = oXMLDOMElement.tagName;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); var nodeBook, namedNodeMap; xmlDoc.setProperty("SelectionLanguage", "XPath"); xmlDoc.async = false; xmlDoc.load("books.xml"); if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { nodeBook = xmlDoc.selectSingleNode("//book"); alert(nodeBook.tagName); }
strValue = oXMLDOMElement.tagName
Dim xmlDoc As New Msxml2.DOMDocument50 Dim nodeBook As IXMLDOMElement Dim namedNodeMap As IXMLDOMNamedNodeMap xmlDoc.setProperty "SelectionLanguage", "XPath" xmlDoc.async = False xmlDoc.Load "books.xml" If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else Set nodeBook = xmlDoc.selectSingleNode("//book") MsgBox nodeBook.tagName End If
HRESULT get_tagName( BSTR *tagName);
tagName
parameter is Null.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(); }
String. The property is read-only. It contains the string that represents the element's name. For example, the tag name in the following tag is "book"
.
<book ISBN="1572318546">
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.
Applies to: IXMLDOMElement