IXMLDOMNode::get_nodeName
Previous | Next |
IXMLDOMNode::get_nodeName
The nodeName method retrieves the qualified name of the element, attribute, or entity reference, or a fixed string for other node types.
Syntax
HRESULT get_nodeName( BSTR* bstrName );
Parameters
bstrName
[out] Pointer to a BSTR containing the node name, which varies depending on the node type.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
The method always retrieves a non-empty string. The get_nodeName method retrieves the name for the element, attribute, or entity reference.
The value of the BSTR retrieved depends on the type of node on which the get_nodeName property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, the name of the XML tag for that element node is retrieved.
Node type | Value retrieved |
NODE_ATTRIBUTE | Retrieves the name of the attribute. |
NODE_COMMENT | Retrieves the literal string "#comment". |
NODE_DOCUMENT | Retrieves the literal string "#document". |
NODE_ELEMENT | Retrieves the name of the XML tag, with any namespace prefix included if present. |
NODE_PROCESSING_INSTRUCTION | Retrieves the target (the first token following the <? Characters). |
NODE_TEXT | Retrieves the literal string "#text". |
Example Code
The following example retrieves a pointer to an IXMLDOMNode interface and retrieves its name.
#include "wmsserver.h" #include <atlbase.h> // Includes CComVariant and CComBSTR. // Declare variables. IWMSServer* pServer; IXMLDOMDocument* pPlaylist; IXMLDOMElement* pXMLElement; IXMLDOMNodeList* pXMLNodeList; IXMLDOMNode* pXMLNode; HRESULT hr; CComVariant varValue; CComBSTR bstrName; VARIANT_BOOL bIsSuccessful; // Initialize the COM library and retrieve a pointer // to an IWMSServer interface. hr = CoInitialize(NULL); hr = CoCreateInstance(CLSID_WMSServer, NULL, CLSCTX_ALL, IID_IWMSServer, (void**)&pServer); if (FAILED(hr)) goto EXIT; // Create the playlist object. hr = pServer->CreatePlaylist(&pPlaylist); // Load a sample playlist file. varValue = "c:\\wmpub\\wmroot\\simple.wsx"; hr = pPlaylist->load(varValue, &bIsSuccessful); if (FAILED(hr)) goto EXIT; if (bIsSuccessful) { // Retrieve a pointer to the IXMLDOMElement interface. hr = pPlaylist->get_documentElement(&pXMLElement); if (FAILED(hr)) goto EXIT; // Retrieve a pointer to the IXMLNodeList interface. hr = pXMLElement->get_childNodes(&pXMLNodeList); if (FAILED(hr)) goto EXIT; // Get the first node in the node list and // retrieve the node name. hr = pXMLNodeList->get_item(0, &pXMLNode); if (FAILED(hr)) goto EXIT; hr = pXMLNode->get_nodeName(&bstrName); if (FAILED(hr)) goto EXIT; } EXIT: // TODO: Release temporary COM objects and uninitialize COM.
Requirements
Header: wmsserver.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003 family, Windows Server 2008 family.
See Also
Previous | Next |