IXMLDOMNode::get_nodeValue
Previous | Next |
IXMLDOMNode::get_nodeValue
The get_nodeValue method retrieves the text associated with the node.
Syntax
HRESULT get_nodeValue( VARIANT* varValue );
Parameters
varValue
[out] Pointer to a VARIANT containing the node value; the node value depends on the get_nodeType method.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
Retrieving the value of the VARIANT depends on the type of node on which the get_nodeValue method is called, as shown in the following table. For example, if the node type is NODE_ATTRIBUTE, a BSTR representing the value for that attribute node is retrieved.
Node type | Value returned |
NODE_ATTRIBUTE | Retrieves a BSTR representing the value of the attribute. For attributes with subnodes, this is the concatenated text of all subnodes with entities expanded. |
NODE_COMMENT | Retrieves the content of the comment, exclusive of the comment's start and end sequence. |
NODE_ELEMENT NODE_DOCUMENT |
Returns NULL. Attempting to set the value of nodes of these types generates an error. |
NODE_PROCESSING_INSTRUCTION | Retrieves the processing instruction, excluding the target. (The target appears in the get_nodeName method.) |
NODE_TEXT | Contains a string representing the text stored in the text node. |
Example Code
The following example retrieves a pointer an IXMLDOMNode interface and tests whether it is a processing instruction node. If it is, its value is retrieved.
#include "wmsserver.h" #include <atlbase.h> // Includes CComVariant and CComBSTR. // Declare variables. IWMSServer* pServer; IXMLDOMDocument* pPlaylist; IXMLDOMNodeList* pXMLNodeList; IXMLDOMNode* pXMLNode; HRESULT hr; CComVariant varValue; CComVariant varNodeValue; CComBSTR bstrType; 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 IXMLNodeList interface. hr = pPlaylist->get_childNodes(&pXMLNodeList); if (FAILED(hr)) goto EXIT; // Get the first node in the node list and // retrieve the node type. hr = pXMLNodeList->get_item(0, &pXMLNode); if (FAILED(hr)) goto EXIT; hr = pXMLNode->get_nodeTypeString(&bstrType); if (FAILED(hr)) goto EXIT; if (bstrType == "processinginstruction") { hr = pXMLNode->get_nodeValue(&varNodeValue); 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 |