本文整理汇总了C++中msxml2::IXMLDOMNamedNodeMapPtr::get_length方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNamedNodeMapPtr::get_length方法的具体用法?C++ IXMLDOMNamedNodeMapPtr::get_length怎么用?C++ IXMLDOMNamedNodeMapPtr::get_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMNamedNodeMapPtr
的用法示例。
在下文中一共展示了IXMLDOMNamedNodeMapPtr::get_length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XMLDOMParsingNodes
//.........这里部分代码省略.........
MessageBox(0,"Error: failed to load XML file. Check the file name.", \
"Load XML file",MB_OK |MB_ICONWARNING);
return;
}
//Collect all or selected nodes by tag name:
NodeListPtr = docPtr->getElementsByTagName(strFindText);
//Output the number of nodes:
//printf("Number of nodes: %d\n", (NodeListPtr->length));
//Output root node:
docPtr->documentElement->get_nodeName(&bstrItemText);
//%ls formatting is for wchar_t* parameter's type (%s for char* type):
printf("\nRoot: %ls\n", bstrItemText);
for(i = 0; i < (NodeListPtr->length); i++)
{
if (pIDOMNode) pIDOMNode->Release();
NodeListPtr->get_item(i, &pIDOMNode);
if(pIDOMNode )
{
pIDOMNode->get_nodeTypeString(&bstrNodeType);
//We process only elements (nodes of "element" type):
BSTR temp = L"element";
if (lstrcmp((LPCTSTR)bstrNodeType, (LPCTSTR)temp)==0)
{
n++;//element node's number
printf("\n\n%d\n", n);//element node's number
printf("Type: %ls\n", bstrNodeType);
pIDOMNode->get_nodeName(&bstrItemNode);
printf("Node: %ls\n", bstrItemNode);
pIDOMNode->get_text(&bstrItemText);
printf("Text: %ls\n", bstrItemText);
pIDOMNode->get_parentNode(&pIParentNode);
pIParentNode->get_nodeName(&bstrItemParent);
printf("Parent: %ls\n",bstrItemParent);
pIDOMNode->get_childNodes(&childList);
printf("Child nodes: %d\n", (childList->length));
//Get the attributes:
int j = 0;//loop-index variable
long length;// number of attributes in the collection
DOMNamedNodeMapPtr = pIDOMNode->attributes;
hResult = DOMNamedNodeMapPtr->get_length(&length);
if(SUCCEEDED(hResult))
{
//Loop through the number of attributes:
for(j = 0; j < length; j++)
{
//get attribute node:
DOMNamedNodeMapPtr->get_item(j,&pIAttrNode);
pIAttrNode->get_nodeTypeString(&bstrAttrType);//type as string
printf("\nAttribute type: %ls\n", bstrAttrType);
//pIAttrNode->get_nodeType(&bstrAttrType);//enumerated type
//printf("Attribute type: %d\n", bstrAttrType);
pIAttrNode->get_nodeName(&bstrAttrName);
printf("Attribute name: %ls\n", bstrAttrName);
pIAttrNode->get_text(&bstrAttrText);
printf("Attribute value: %ls\n", bstrAttrText);
}
}
// ::MessageBox(NULL, (LPCSTR) bstrItemText,"parsing", MB_OK);
}
}
}
//Do not forget to release interfaces:
pIDOMNode->Release();
pIDOMNode = NULL;
pIParentNode->Release();
pIParentNode = NULL;
}
catch(...)
{
MessageBox(NULL, ("*** Exception occurred ***"), ("Error message"), MB_OK);
}
CoUninitialize();
}