本文整理汇总了C++中IXMLDOMNode::get_nodeName方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::get_nodeName方法的具体用法?C++ IXMLDOMNode::get_nodeName怎么用?C++ IXMLDOMNode::get_nodeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::get_nodeName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConfGetListNodeByName
/**
* получение xml-узла из списка по его имени
* @param NodeName имя искомого узла
* @param pIDOMNodeList дескриптор списка
* @return дескриптор нужного узла, или NULL в случае неудачи
* @see ConfGetNodeByName()
* @see ConfGetNodeText()
* @see ConfGetTextByName()
*/
IXMLDOMNode * ConfGetListNodeByName(BSTR NodeName, IXMLDOMNodeList *pIDOMNodeList)
{
IXMLDOMNode *Ret = NULL;
LONG len = 0;
if (pIDOMNodeList == NULL)
{
return NULL;
}
HRESULT hr = pIDOMNodeList->get_length(&len);
if (SUCCEEDED(hr))
{
pIDOMNodeList->reset();
for (int i = 0; i < len; i++)
{
IXMLDOMNode *pIDOMChildNode = NULL;
hr = pIDOMNodeList->get_item(i, &pIDOMChildNode);
if (SUCCEEDED(hr))
{
BSTR ChildNodeName = NULL;
hr = pIDOMChildNode->get_nodeName(&ChildNodeName);
if (SUCCEEDED(hr))
{
if (!wcscmp(NodeName, ChildNodeName))
{
Ret = pIDOMChildNode;
}
}
if (ChildNodeName)
{
SysFreeString(ChildNodeName);
}
if (Ret)
{
return Ret;
}
pIDOMChildNode->Release();
pIDOMChildNode = NULL;
}
else
{
DbgMsg(__FILE__, __LINE__, "pIDOMNodeList->get_item() ERROR 0x%.8x\n", hr);
}
}
}
else
{
DbgMsg(__FILE__, __LINE__, "pIDOMNodeList->get_length() ERROR 0x%.8x\n", hr);
}
return NULL;
}
示例2: xmlGetAttributeValueBOOL
BOOL TxSkin::elVBOX::loadXML( IXMLDOMNode* node, LPCWSTR baseurl )
{
BOOL ret = skin_element::loadXML(node, baseurl);
m_adapt = xmlGetAttributeValueBOOL(node, TEXT("adapt"), TRUE);
IXMLDOMNode* child = NULL;
node->get_firstChild(&child);
while(child)
{
BSTR name = NULL;
child->get_nodeName(&name);
if(name)
{
skin_element* el = m_skin->createElement(name, m_skin);
if(el)
{
if(el->loadXML(child, baseurl))
{
addElement(el);
} else
{
delete el;
}
}
SysFreeString(name);
}
IXMLDOMNode* newChild = NULL;
child->get_nextSibling(&newChild);
child->Release();
child = newChild;
}
return ret;
}
示例3: 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);
//.........这里部分代码省略.........
示例4: 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();
}
}
示例5: LoadDialogStatesFromXML
void Explorerplusplus::LoadDialogStatesFromXML(IXMLDOMDocument *pXMLDom)
{
IXMLDOMNodeList *pNodes = NULL;
IXMLDOMNode *pNode = NULL;
IXMLDOMNamedNodeMap *am = NULL;
IXMLDOMNode *pChildNode = NULL;
BSTR bstrName;
BSTR bstrValue;
BSTR bstr = NULL;
HRESULT hr;
long length;
long lChildNodes;
if(pXMLDom == NULL)
goto clean;
TCHAR tempNodeSelector[64];
StringCchPrintf(tempNodeSelector, SIZEOF_ARRAY(tempNodeSelector),
_T("//%s/*"), DIALOGS_XML_KEY);
bstr = SysAllocString(tempNodeSelector);
pXMLDom->selectNodes(bstr,&pNodes);
if(!pNodes)
{
goto clean;
}
else
{
pNodes->get_length(&length);
for(long i = 0;i < length;i++)
{
/* This should never fail, as the number
of nodes has already been counted (so
they must exist). */
hr = pNodes->get_item(i,&pNode);
if(SUCCEEDED(hr))
{
hr = pNode->get_attributes(&am);
if(SUCCEEDED(hr))
{
/* Retrieve the total number of attributes
attached to this node. */
am->get_length(&lChildNodes);
if(lChildNodes >= 1)
{
am->get_item(0,&pChildNode);
pChildNode->get_nodeName(&bstrName);
pChildNode->get_text(&bstrValue);
for(CDialogSettings *ds : DIALOG_SETTINGS)
{
TCHAR settingsKey[64];
bool success = ds->GetSettingsKey(settingsKey, SIZEOF_ARRAY(settingsKey));
assert(success);
if(!success)
{
continue;
}
if(lstrcmpi(bstrValue, settingsKey) == 0)
{
ds->LoadXMLSettings(am, lChildNodes);
}
}
}
}
}
pNode->Release();
pNode = NULL;
}
}
clean:
if (bstr) SysFreeString(bstr);
if (pNodes) pNodes->Release();
if (pNode) pNode->Release();
}
示例6: 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;
}
示例7: GetNodePath
/*
Function name : CXML::GetNodePath
Description : This function will return the full path of the xml file. (Max up to
: 100 Nodes)
Return type : bool
Argument : CString &rcsPath
Tested : Ok
*/
bool CXML::GetNodePath(CString &rcsPath)
{
if(!m_pICurrentNode)
return false;
char * path[100] = {0};
IXMLDOMNode * pCurNode = m_pICurrentNode;
IXMLDOMNode * pParentNode = NULL;
pCurNode->AddRef();
CString csNodeText;
int i = 0;
try
{
do
{
m_hr = pCurNode->get_parentNode(&pParentNode);
if(!SUCCEEDED(m_hr))
{
pCurNode->Release();
throw 1;
}
else if(!pParentNode)
break;
BSTR bstrNodeText;
m_hr = pParentNode->get_nodeName(&bstrNodeText);
pCurNode->Release();
pCurNode = pParentNode;
pCurNode->AddRef();
pParentNode->Release();
if(!SUCCEEDED(m_hr))
{
throw 1;
}
long nLen = wcslen(bstrNodeText)+1;
path[i] = new char[nLen];
WideCharToMultiByte(CP_ACP,0,bstrNodeText,-1,path[i],nLen,NULL,NULL);
SysFreeString(bstrNodeText);
i++;
}
while(true);
delete [] path[--i];
for(--i;i>=0;--i)
{
rcsPath += path[i];
rcsPath +="/";
delete [] path[i];
}
GetCurrentNodeName(csNodeText);
rcsPath +=csNodeText;
return true;
}
catch(...)
{
rcsPath = "";
for(--i;i>=0;--i)
delete [] path[i];
return false;
}
}
示例8: queryNodes
void queryNodes()
{
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNodeList *pNodes = NULL;
IXMLDOMNode *pNode = NULL;
BSTR bstrQuery1 = NULL;
BSTR bstrQuery2 = NULL;
BSTR bstrNodeName = NULL;
BSTR bstrNodeValue = NULL;
VARIANT_BOOL varStatus;
VARIANT varFileName;
VariantInit(&varFileName);
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(L"stocks.xml", varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
// Query a single node.
bstrQuery1 = SysAllocString(L"//stock[1]/*");
CHK_ALLOC(bstrQuery1);
CHK_HR(pXMLDom->selectSingleNode(bstrQuery1, &pNode));
if (pNode)
{
printf("Result from selectSingleNode:\n");
CHK_HR(pNode->get_nodeName(&bstrNodeName));
printf("Node, <%S>:\n", bstrNodeName);
SysFreeString(bstrNodeName);
CHK_HR(pNode->get_xml(&bstrNodeValue));
printf("\t%S\n\n", bstrNodeValue);
SysFreeString(bstrNodeValue);
SAFE_RELEASE(pNode);
}
else
{
CHK_HR(ReportParseError(pXMLDom, "Error while calling selectSingleNode."));
}
// Query a node-set.
bstrQuery2 = SysAllocString(L"//stock[1]/*");
CHK_ALLOC(bstrQuery2);
CHK_HR(pXMLDom->selectNodes(bstrQuery2, &pNodes));
if(pNodes)
{
printf("Results from selectNodes:\n");
//get the length of node-set
long length;
CHK_HR(pNodes->get_length(&length));
for (long i = 0; i < length; i++)
{
CHK_HR(pNodes->get_item(i, &pNode));
CHK_HR(pNode->get_nodeName(&bstrNodeName));
/*if(0== wcscmp(bstrNodeValue, L"symbol"))
{
}
*/
printf("Node (%d), <%S>:\n", i, bstrNodeName);
SysFreeString(bstrNodeName);
CHK_HR(pNode->get_xml(&bstrNodeValue));
printf("\t%S\n", bstrNodeValue);
SysFreeString(bstrNodeValue);
SAFE_RELEASE(pNode);
}
}
else
{
CHK_HR(ReportParseError(pXMLDom, "Error while calling selectNodes."));
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pNodes);
SAFE_RELEASE(pNode);
SysFreeString(bstrQuery1);
SysFreeString(bstrQuery2);
SysFreeString(bstrNodeName);
SysFreeString(bstrNodeValue);
VariantClear(&varFileName);
}