本文整理汇总了C++中IXMLDOMNode::get_nodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::get_nodeValue方法的具体用法?C++ IXMLDOMNode::get_nodeValue怎么用?C++ IXMLDOMNode::get_nodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::get_nodeValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAttributeFromNode
HRESULT XMLHelper::GetAttributeFromNode(IXMLDOMNode *pNode, BSTR bstrAttrName, VARIANT * varAttrValue)
{
HRESULT hr = S_OK;
IXMLDOMNamedNodeMap *pAttributes = NULL;
IXMLDOMNode *pAttrNode = NULL;
CHK_HR(pNode->get_attributes(&pAttributes));
if (pAttributes)
{
CHK_HR(pAttributes->getNamedItem(bstrAttrName, &pAttrNode));
if (pAttrNode)
{
CHK_HR(pAttrNode->get_nodeValue(varAttrValue));
}
}
else
{
hr = S_FALSE;
}
CleanUp:
SAFE_RELEASE(pAttributes);
SAFE_RELEASE(pAttrNode);
return hr;
}
示例2: GetAttribFromNode
//--------------------------------------------------------------------------------------
HRESULT CRatingsDB::GetAttribFromNode( IXMLDOMNode* pNode, WCHAR* strAttrib, WCHAR* strDest, int cchDest )
{
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap = nullptr;
BSTR bstrAttributeName = ::SysAllocString( strAttrib );
IXMLDOMNode* pIXMLDOMNode = nullptr;
bool bFound = false;
HRESULT hr;
VARIANT v;
hr = pNode->get_attributes( &pIXMLDOMNamedNodeMap );
if(SUCCEEDED(hr) && pIXMLDOMNamedNodeMap)
{
hr = pIXMLDOMNamedNodeMap->getNamedItem( bstrAttributeName, &pIXMLDOMNode );
if(SUCCEEDED(hr) && pIXMLDOMNode)
{
pIXMLDOMNode->get_nodeValue(&v);
if( SUCCEEDED(hr) && v.vt == VT_BSTR )
{
wcscpy_s( strDest, cchDest, v.bstrVal );
bFound = true;
}
VariantClear(&v);
SAFE_RELEASE( pIXMLDOMNode );
}
SAFE_RELEASE( pIXMLDOMNamedNodeMap );
}
::SysFreeString(bstrAttributeName);
bstrAttributeName = nullptr;
if( !bFound )
return E_FAIL;
else
return S_OK;
}
示例3: GetAttributeText
int ZXML::GetAttributeText( IXMLDOMNode* pNode, LPSTR strAttrName, LPSTR strRet )
{
wchar_t wstrAttr[128];
IXMLDOMNode* pAttrNode = NULL;
IXMLDOMNamedNodeMap* pMap = NULL;
VARIANT varValue;
try
{
int n = mbstowcs( wstrAttr, strAttrName, 128 );
pNode->get_attributes( &pMap );
pMap->getNamedItem( wstrAttr, &pAttrNode );
pAttrNode->get_nodeValue( &varValue );
strcpy( strRet,(const char*)_bstr_t(varValue.bstrVal,FALSE) );
// wcstombs( strRet, varValue.bstrVal , 128 );
S_REL( pAttrNode );
S_REL( pMap );
return TRUE;
}
catch(...)
{
S_REL( pAttrNode );
S_REL( pMap );
return FALSE;
}
}
示例4: GetNodeAttributeValue
bool CXML::GetNodeAttributeValue(IXMLDOMNode ** ppNode,CString csAttributeName,CString &rcsValue)
{
IXMLDOMNode *pNodeAttribute = NULL;
IXMLDOMNamedNodeMap *pNodeMap = NULL;
CString csTemp;
if(!ppNode || !(*ppNode))
return false;
m_hr = (*ppNode)->get_attributes(&pNodeMap);
if (SUCCEEDED(m_hr) == 0 || pNodeMap == NULL)
return false;
_bstr_t bstrAttributeName(csAttributeName);
m_hr = pNodeMap->getNamedItem (bstrAttributeName,&pNodeAttribute);
pNodeMap->Release();
if (SUCCEEDED(m_hr) == 0 || (pNodeAttribute == NULL))
return false;
_variant_t vtAttributeVal;
m_hr = pNodeAttribute->get_nodeValue(&vtAttributeVal);
pNodeAttribute->Release();
if (SUCCEEDED(m_hr) == 0)
return false;
rcsValue = vtAttributeVal.bstrVal;
return true;
}
示例5: GetAttributeText
int KXML::GetAttributeText(IXMLDOMNode* pNode, LPSTR strAttrName, LPSTR strRet){
wchar_t wstrAttr[128];
IXMLDOMNode* pAttrNode = NULL;
IXMLDOMNamedNodeMap* pMap = NULL;
VARIANT varValue;
try{
//int n = mbstowcs(wstrAttr, strAttrName, 128);
//int n = mbstowcs_s(wstrAttr, strAttrName, 128);
// TODO : error test
size_t convertedSize;
int n = mbstowcs_s(&convertedSize, wstrAttr, strlen(strAttrName) + 1, strAttrName, 128);
pNode->get_attributes(&pMap);
pMap->getNamedItem(wstrAttr, &pAttrNode);
pAttrNode->get_nodeValue(&varValue);
strcpy_s(strRet, 128, (const char*)_bstr_t(varValue.bstrVal, FALSE));
// wcstombs(strRet, varValue.bstrVal, 128)
REL(pAttrNode);
REL(pMap);
return TRUE;
}
catch (...){
REL(pAttrNode);
REL(pMap);
return FALSE;
}
}
示例6: XMLGetAttrTrim
static bool XMLGetAttrTrim( //return true only if an attribute with name pszwAttr found
IXMLDOMNode* pNode, //node where to get attribute from
const wchar_t* pszwAttr, //Name of attribute to get
wchar_t szAttrVal[MAX_PATH] //buffer for result
)
{
HRESULT hr;
VARIANT val;
wchar_t* pszWchar;
int nLen;
IXMLDOMNode* pAttr;
IXMLDOMNamedNodeMap* pAList;
szAttrVal[0] = 0;
pAList = NULL;
pAttr = NULL;
pNode->get_attributes(&pAList);
if(pAList)
{
pAList->getNamedItem((wchar_t*)pszwAttr, &pAttr);
FC_RELEASE_PTR(pAList);
}
if(!pAttr)
return false;
VariantInit(&val);
hr = pAttr->get_nodeValue(&val);
FC_RELEASE_PTR(pAttr);
if(FAILED(hr) || val.vt!=VT_BSTR)
{
VariantClear(&val);
return false;
}
//trim the string:
pszWchar = val.bstrVal;
while(_istspace(*pszWchar))
pszWchar++;
for(nLen=wcslen(pszWchar);nLen>0 && _istspace(pszWchar[nLen-1]);nLen--)
pszWchar[nLen-1] = 0;
wcsncpy(szAttrVal, pszWchar, MAX_PATH);
szAttrVal[MAX_PATH-1] = 0;
VariantClear(&val);
return true;
}
示例7: GetXmlAttribute
inline bool GetXmlAttribute(IXMLDOMNamedNodeMap *attributes, const wchar_t *name, CGrVector &v)
{
IXMLDOMNode *node;
CComBSTR nameB = name;
attributes->getNamedItem(nameB, &node);
if(node == NULL)
return false;
CComVariant valueV;
node->get_nodeValue(&valueV);
std::wstringstream str(valueV.bstrVal);
double x, y, z, w;
str >> x >> y >> z >> w;
v.Set(x, y, z, w);
return true;
}
示例8: ConfGetNodeAttributeW
//--------------------------------------------------------------------------------------
BOOL ConfGetNodeAttributeW(IXMLDOMNode *pIDOMNode, PWSTR name, PWSTR *value)
{
BOOL bRet = FALSE;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap = NULL;
// query attributes map
HRESULT hr = pIDOMNode->get_attributes(&pIXMLDOMNamedNodeMap);
if (SUCCEEDED(hr) && pIXMLDOMNamedNodeMap)
{
IXMLDOMNode *pIDOMAttrNode = NULL;
// query attribute node
hr = pIXMLDOMNamedNodeMap->getNamedItem(name, &pIDOMAttrNode);
if (SUCCEEDED(hr) && pIDOMAttrNode)
{
VARIANT varValue;
hr = pIDOMAttrNode->get_nodeValue(&varValue);
if (FAILED(hr))
{
DbgMsg(__FILE__, __LINE__, "pIDOMAttrNode->get_nodeValue() ERROR 0x%.8x\n", hr);
goto free;
}
BSTR val = _bstr_t(varValue);
DWORD Len = (wcslen((PWSTR)val) + 1) * sizeof(WCHAR);
if (*value = (PWSTR)M_ALLOC(Len))
{
ZeroMemory(*value, Len);
wcscpy(*value, (PWSTR)val);
bRet = TRUE;
}
else
{
DbgMsg(__FILE__, __LINE__, "M_ALLOC() ERROR %d\n", GetLastError());
}
free:
pIDOMAttrNode->Release();
pIDOMAttrNode = NULL;
}
pIXMLDOMNamedNodeMap->Release();
pIXMLDOMNamedNodeMap = NULL;
}
return bRet;
}
示例9: GetTextWithAttributeName
bool CNtlXMLDoc::GetTextWithAttributeName(IXMLDOMNode* pNode, WCHAR* pwszAttributeName, WCHAR* pwszResultText, int nBufferSizeInWChars)
{
if (NULL == pNode || NULL == pwszAttributeName || NULL == pwszResultText)
{
// NtlAssertFail("NULL == pNode || NULL == pwszAttributeName || NULL == pwszResultText");
return false;
}
if (0 >= nBufferSizeInWChars)
{
// NtlAssertFail("0 >= nBufferSizeInWChars");
return false;
}
IXMLDOMNamedNodeMap* pMap = NULL;
pNode->get_attributes(&pMap);
if (NULL == pMap)
{
// NtlAssertFail("Couldn't get the attribute list from the given IXMLDOMNode.");
return false;
}
IXMLDOMNode* pVirtualNode = NULL;
pMap->getNamedItem(pwszAttributeName, &pVirtualNode);
if (NULL == pVirtualNode)
{
// NtlAssertFail("Couldn't find the given attribute name.");
return false;
}
VARIANT var;
VariantInit(&var);
pVirtualNode->get_nodeValue(&var);
if (wcslen(V_BSTR(&var)) >= (size_t)nBufferSizeInWChars)
{
// NtlAssertFail("The buffer size is not enough to take the whole attribute value.");
return false;
}
wcscpy_s(pwszResultText, nBufferSizeInWChars, V_BSTR(&var));
return true;
}
示例10: put_RecognitionParam
STDMETHODIMP CStrokeRecognition::put_RecognitionParam(BSTR newVal)
{
double Segment_Error_Threshold;
double Arc_Error_Threshold;
double Arc_Min_Length;
double Arc_Min_Curve;
double Stroke_Min_Length;
double Min_Turning_Angle;
double Segmentation_Penalty;
VARIANT value;
BSTR nodeName;
long n;
IXMLDOMDocument* pDoc;
IXMLDOMNodeList* pNodeList;
IXMLDOMNode* pNode;
IXMLDOMNode* pParamNode;
IXMLDOMNode* pAttrNode;
IXMLDOMNamedNodeMap* pNodeMap;
VARIANT_BOOL bLoaded;
GetFittingParam(Segment_Error_Threshold, Arc_Error_Threshold, Arc_Min_Length, Arc_Min_Curve, Stroke_Min_Length, Min_Turning_Angle, Segmentation_Penalty);
if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc)))
{
pDoc->put_async(VARIANT_FALSE);
pDoc->loadXML(newVal, &bLoaded);
if (bLoaded == VARIANT_TRUE)
{
if (SUCCEEDED(pDoc->get_childNodes(&pNodeList)))
{
pParamNode = NULL;
pNodeList->get_length(&n);
for (int i = 0; i < n; i++)
{
if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
{
nodeName = NULL;
if (SUCCEEDED(pNode->get_nodeName(&nodeName)))
{
if (CComBSTR(nodeName) == L"param")
{
pParamNode = pNode;
pParamNode->AddRef();
break;
}
SysFreeString(nodeName);
}
pNode->Release();
}
}
pNodeList->Release();
if (pParamNode != NULL)
{
if (SUCCEEDED(pParamNode->get_attributes(&pNodeMap)))
{
if (SUCCEEDED(pNodeMap->getNamedItem(L"Segment_Error_Threshold", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Segment_Error_Threshold = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Error_Threshold", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Arc_Error_Threshold = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Length", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Arc_Min_Length = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Curve", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Arc_Min_Curve = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Stroke_Min_Length", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Stroke_Min_Length = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Min_Turning_Angle", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
Min_Turning_Angle = _wtof(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"Segmentation_Penalty", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
//.........这里部分代码省略.........
示例11: DecodePointFromXML
void CStrokeRecognition::DecodePointFromXML(std::vector<POINT> &rgPoints, BSTR strXML)
{
IXMLDOMDocument* pDoc;
IXMLDOMNodeList* pNodeList;
IXMLDOMNode* pNode;
IXMLDOMNode* pInputNode;
IXMLDOMNode* pAttrNode;
IXMLDOMNamedNodeMap* pNodeMap;
VARIANT_BOOL bLoaded;
VARIANT value;
BSTR nodeName;
POINT pt;
long n;
if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc)))
{
pDoc->put_async(VARIANT_FALSE);
pDoc->loadXML(strXML, &bLoaded);
if (bLoaded == VARIANT_TRUE)
{
if (SUCCEEDED(pDoc->get_childNodes(&pNodeList)))
{
pInputNode = NULL;
pNodeList->get_length(&n);
for (int i = 0; i < n; i++)
{
if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
{
nodeName = NULL;
if (SUCCEEDED(pNode->get_nodeName(&nodeName)))
{
if (CComBSTR(nodeName) == L"input")
{
pInputNode = pNode;
pInputNode->AddRef();
break;
}
SysFreeString(nodeName);
}
pNode->Release();
}
}
pNodeList->Release();
if (pInputNode != NULL)
{
if (SUCCEEDED(pInputNode->get_childNodes(&pNodeList)))
{
pNodeList->get_length(&n);
for (int i = 0; i < n; i++)
{
if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
{
pt.x = 0;
pt.y = 0;
if (SUCCEEDED(pNode->get_attributes(&pNodeMap)))
{
if (SUCCEEDED(pNodeMap->getNamedItem(L"x", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
pt.x = _wtoi(value.bstrVal);
pAttrNode->Release();
}
if (SUCCEEDED(pNodeMap->getNamedItem(L"y", &pAttrNode)))
{
pAttrNode->get_nodeValue(&value);
pt.y = _wtoi(value.bstrVal);
pAttrNode->Release();
}
pNodeMap->Release();
}
rgPoints.push_back(pt);
pNode->Release();
}
}
pNodeList->Release();
}
pInputNode->Release();
}
}
}
pDoc->Release();
}
}
示例12: read_config_file
/**Read the XML config file. Currently contains keyboard choices.*/
void read_config_file()
{
TrainerConfig *result = new TrainerConfig();
CoInitialize(NULL);
//read XML
MSXML2::IXMLDOMDocumentPtr spXMLDoc;
spXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
if (!spXMLDoc->load("ent-config.xml"))
{
write_text_to_log_file("No config found, using defaults");
config = result; //the default config
}
IXMLDOMNodeListPtr nodes = spXMLDoc->selectNodes(L"//ent-config/keys/key");
long length;
nodes->get_length(&length);
for (int i = 0; i < length; i++)
{
IXMLDOMNode *node;
nodes->get_item(i, &node);
IXMLDOMNamedNodeMap *attribs;
node->get_attributes(&attribs);
long length_attribs;
attribs->get_length(&length_attribs);
char *attrib_key_func = NULL;
char *attrib_key_value = NULL;
for (long j = 0; j < length_attribs; j++)
{
IXMLDOMNode *attribNode;
attribs->get_item(j, &attribNode);
attribNode->get_nodeName(&bstr);
if (wcscmp(bstr, L"function") == 0)
{
VARIANT var;
VariantInit(&var);
attribNode->get_nodeValue(&var);
attrib_key_func = _com_util::ConvertBSTRToString(V_BSTR(&var));
}
else if (wcscmp(bstr, L"value") == 0)
{
VARIANT var;
VariantInit(&var);
attribNode->get_nodeValue(&var);
attrib_key_value = _com_util::ConvertBSTRToString(V_BSTR(&var));
}
SysFreeString(bstr);
attribNode->Release();
}
if (attrib_key_func != NULL && attrib_key_value != NULL)
{
result->get_key_config()->set_key(attrib_key_func, attrib_key_value);
}
delete attrib_key_func;
delete attrib_key_value;
attribs->Release();
node->Release();
}
//nodes->Release(); //don't do this, it crashes on exit
spXMLDoc.Release();
CoUninitialize();
config = result;
}