本文整理汇总了C++中msxml2::IXMLDOMNode::get_nodeName方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::get_nodeName方法的具体用法?C++ IXMLDOMNode::get_nodeName怎么用?C++ IXMLDOMNode::get_nodeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::get_nodeName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SysAllocString
TEST_FIXTURE(XmlFixture, CreateChild2)
{
MSXML2::IXMLDOMNode *node = 0;
HRESULT hr = XMLHelper::CreateChild(root, &node, _T("test"));
CHECK_OK(hr);
CHECK(node);
node->Release();
node = 0;
BSTR query = SysAllocString(_T("//test"));
MSXML2::IXMLDOMNodeList *nodeList = 0;
hr = doc->selectNodes(query, &nodeList);
SysFreeString(query);
CHECK_OK(hr);
CHECK(nodeList);
long length = 0;
hr = nodeList->get_length(&length);
CHECK_OK(hr);
CHECK_EQUAL(1, length);
hr = nodeList->nextNode(&node);
CHECK_OK(hr);
CHECK(node);
BSTR name = 0;
hr = node->get_nodeName(&name);
CHECK_OK(hr);
CHECK_EQUAL(0, _tcscmp(name, _T("test")));
SysFreeString(name);
}
示例2: LoadXMLSettings
void CDialogSettings::LoadXMLSettings(MSXML2::IXMLDOMNamedNodeMap *pam,long lChildNodes)
{
MSXML2::IXMLDOMNode *pNode = NULL;
BSTR bstrName;
BSTR bstrValue;
for(int i = 1;i < lChildNodes;i++)
{
pam->get_item(i,&pNode);
pNode->get_nodeName(&bstrName);
pNode->get_text(&bstrValue);
bool bHandled = false;
if(m_bSavePosition)
{
if(lstrcmpi(bstrName, SETTING_POSITION_X) == 0)
{
m_ptDialog.x = NXMLSettings::DecodeIntValue(bstrValue);
bHandled = true;
}
else if(lstrcmpi(bstrName, SETTING_POSITION_Y) == 0)
{
m_ptDialog.y = NXMLSettings::DecodeIntValue(bstrValue);
bHandled = true;
}
else if(lstrcmpi(bstrName, SETTING_WIDTH) == 0)
{
m_iWidth = NXMLSettings::DecodeIntValue(bstrValue);
bHandled = true;
}
else if(lstrcmpi(bstrName, SETTING_HEIGHT) == 0)
{
m_iHeight = NXMLSettings::DecodeIntValue(bstrValue);
bHandled = true;
}
}
if(!bHandled)
{
/* Pass the node name and value to any
descendant class to handle. */
LoadExtraXMLSettings(bstrName,bstrValue);
}
}
m_bStateSaved = TRUE;
}
示例3: XMLDOMParsingNodes
void XMLDOMParsingNodes(char *szFileName)
{
try
{
//Qualify namespase explicitly to avoid Compiler Error C2872 "ambiguous symbol" during linking.
//Now Msxml2.dll use the "MSXML2" namespace
//(see http://support.microsoft.com/default.aspx?scid=kb;en-us;316317):
MSXML2::IXMLDOMDocumentPtr docPtr;//pointer to DOMDocument object
MSXML2::IXMLDOMNodeListPtr NodeListPtr;//indexed access. and iteration through the collection of nodes
MSXML2::IXMLDOMNodePtr DOMNodePtr;//pointer to the node
MSXML2::IXMLDOMNode *pIDOMNode = NULL;//pointer to element's node
MSXML2::IXMLDOMNode *pIParentNode = NULL;//pointer to parent node
MSXML2::IXMLDOMNode *pIAttrNode = NULL;//pointer to attribute node
MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr;//iteration through the collection of attribute nodes
MSXML2::IXMLDOMNodeList *childList=NULL;//node list containing the child nodes
//Variable with the name of node to find:
BSTR strFindText = L" ";//" " means to output every node
//Variables to store item's name, parent, text and node type:
BSTR bstrItemText,bstrItemNode, bstrItemParent,bstrNodeType;
//Variables to store attribute's name,type and text:
BSTR bstrAttrName, bstrAttrType, bstrAttrText;
HRESULT hResult;
int i = 0;//loop-index variable
int n = 0;//lines counter
//Initialize COM Library:
CoInitialize(NULL);
//Create an instance of the DOMDocument object:
docPtr.CreateInstance(__uuidof(DOMDocument30));
// Load a document:
_variant_t varXml(szFileName);//XML file to load
_variant_t varResult((bool)TRUE);//result
varResult = docPtr->load(varXml);
if ((bool)varResult == FALSE)
{
//printf("*** Error:failed to load XML file. ***\n");
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));
//.........这里部分代码省略.........
示例4: ND_nGetTableRowCount
UINT XMLPaser::ND_nGetTableRowCount( LPCTSTR strTable )
{
UINT nItemCount = 0;
MSXML2::IXMLDOMNode *pNode = NULL;
try
{
pNode = ND_pGetTableNode( strTable );
if ( pNode )
{
MSXML2::IXMLDOMNamedNodeMap* pNodeMap;
if ( SUCCEEDED( pNode->get_attributes( &pNodeMap ) ) && pNodeMap )
{
MSXML2::IXMLDOMNode *pAttributeNode = NULL;
for ( long i = 0; i < pNodeMap->Getlength(); i++ )
{
pNodeMap->get_item( i, &pAttributeNode );
if ( pAttributeNode )
{
BSTR bstrName;
_variant_t varRowName;
pAttributeNode->get_nodeName( &bstrName );
LPSTR pszName;
UnicodeToAnsi( bstrName, &pszName );
if ( strcmp( pszName, _T("ss:ExpandedRowCount") ) == 0 )
{
pAttributeNode->get_nodeValue( &varRowName );
if ( varRowName.vt == VT_BSTR )
{
LPSTR pszTableName;
UnicodeToAnsi( varRowName.bstrVal, &pszTableName );
nItemCount = atoi( pszTableName );
CoTaskMemFree( pszTableName );
}
}
CoTaskMemFree( pszName );
pAttributeNode->Release();
VariantClear( &varRowName );
::SysFreeString( bstrName );
}
}
pNodeMap->Release();
}
pNode->Release();
}
return ( nItemCount );
}
catch(...)
{
return ( 0 );
}
}
示例5: ND_pGetTableNode
// 이 함수의 리턴 값인 IXMLDOMNode 포인터는 쓰고 난 후에 Release를 해야한다.
MSXML2::IXMLDOMNode* XMLPaser::ND_pGetTableNode( LPCTSTR strTable )
{
MSXML2::IXMLDOMNode *pWorksheetNode = NULL;
MSXML2::IXMLDOMNode *pTableNode = NULL;
long lFoundWorksheet = -1;
try
{
m_pNodeList->reset();
for ( long i = 0; i < m_lTableCount; i++ )
{
m_pNodeList->get_item( i, &pWorksheetNode );
if ( pWorksheetNode )
{
MSXML2::IXMLDOMNamedNodeMap* pNodeMap;
if ( SUCCEEDED( pWorksheetNode->get_attributes( &pNodeMap ) ) && pNodeMap )
{
MSXML2::IXMLDOMNode *pAttributeNode = NULL;
pNodeMap->get_item( 0, &pAttributeNode );
if ( pAttributeNode )
{
BSTR bstrName;
_variant_t varTableName;
pAttributeNode->get_nodeName( &bstrName );
LPSTR pszName;
UnicodeToAnsi( bstrName, &pszName );
if ( strcmp( pszName, _T("ss:Name") ) == 0 )
{
pAttributeNode->get_nodeValue( &varTableName );
if ( varTableName.vt == VT_BSTR )
{
LPSTR pszTableName;
UnicodeToAnsi( varTableName.bstrVal, &pszTableName );
// Found Worksheet!
if ( stricmp( strTable, pszTableName ) == 0 )
{
lFoundWorksheet = i;
}
CoTaskMemFree( pszTableName );
}
}
CoTaskMemFree( pszName );
pAttributeNode->Release();
VariantClear( &varTableName );
::SysFreeString( bstrName );
}
pNodeMap->Release();
}
pWorksheetNode->Release();
}
}
if ( lFoundWorksheet < 0 )
throw ( 0 );
m_pNodeList->get_item( lFoundWorksheet, &pWorksheetNode );
if ( pWorksheetNode )
{
MSXML2::IXMLDOMNodeList* pNodeList;
pWorksheetNode->get_childNodes( &pNodeList );
if ( pNodeList )
{
for ( long i = 0; i < pNodeList->Getlength(); i++ )
{
pNodeList->get_item( i, &pTableNode );
if ( pTableNode )
{
BSTR bstrName;
pTableNode->get_nodeName( &bstrName );
LPSTR pszName;
UnicodeToAnsi( bstrName, &pszName );
if ( strcmp( pszName, _T("Table") ) == 0 )
{
CoTaskMemFree( pszName );
::SysFreeString( bstrName );
pNodeList->Release();
pWorksheetNode->Release();
return ( pTableNode );
}
CoTaskMemFree( pszName );
::SysFreeString( bstrName );
}
}
pNodeList->Release();
}
pWorksheetNode->Release();
}
//.........这里部分代码省略.........