本文整理汇总了C++中msxml2::IXMLDOMNodeListPtr类的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNodeListPtr类的具体用法?C++ IXMLDOMNodeListPtr怎么用?C++ IXMLDOMNodeListPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IXMLDOMNodeListPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveSelection
void CSimpleFilterDialog::SaveSelection(void)
{
POSITION pos = m_ResultList.GetFirstSelectedItemPosition();
//okopiruje vzorovy element selection
MSXML2::IXMLDOMElementPtr selection_elem = m_active_element->ownerDocument->createElement("selection");
MSXML2::IXMLDOMAttributePtr id_attr = m_active_element->ownerDocument->createAttribute("id");
selection_elem->setAttributeNode(id_attr);
id_attr.Release();
//vymaze vsechny selection
MSXML2::IXMLDOMNodeListPtr list = m_cloned_active_element->selectNodes("filter[@type='simple']/selection");
MSXML2::IXMLDOMSelection * sel;
list.QueryInterface(__uuidof(MSXML2::IXMLDOMSelection), &sel);
sel->removeAll();
sel->Release();
MSXML2::IXMLDOMNodePtr filter = m_cloned_active_element->selectSingleNode("filter[@type='simple']");
while (pos)
{
int nItem = m_ResultList.GetNextSelectedItem(pos);
selection_elem->setAttribute("id", (LPCTSTR) m_ResultList.GetItemText(nItem, 0));
filter->appendChild(selection_elem->cloneNode(VARIANT_FALSE));
}
selection_elem.Release();
}
示例2: msiInstall
CA_API UINT __stdcall Xml_DeleteNodes(MSIHANDLE hInstall)
{
MSI_EXCEPTION_HANDLER_PROLOG;
MsiInstall msiInstall(hInstall);
std::wstring filename = msiInstall.GetProperty(L"XML_FILENAME");
AppSecInc::Xml::XmlDocument doc;
doc.Load(filename);
std::wstring xpath = msiInstall.GetProperty(L"XML_XPATH");
MSXML2::IXMLDOMNodeListPtr nodes = doc.FindNodes(xpath);
int count = 0;
if (NULL != nodes)
{
MSXML2::IXMLDOMNodePtr node = NULL;
while (NULL != (node = nodes->nextNode()))
{
node->parentNode->removeChild(node);
count++;
}
}
if (count > 0)
{
CHECK_HR(doc->save(CComVariant(filename.c_str())),
L"Error saving '" << filename << L"'");
}
msiInstall.SetProperty(L"XML_DELETED", AppSecInc::StringUtils::toWString(count));
MSI_EXCEPTION_HANDLER_EPILOG;
return ERROR_SUCCESS;
}
示例3: ReadDeviceDescription
MTConnectDataModel MTConnectDeviceParser::ReadDeviceDescription(std::string filename)
{
MTConnectDataModel dataItems;
dataItems.clear();
if(GetFileAttributesA(filename.c_str())== INVALID_FILE_ATTRIBUTES)
{
filename= ::ExeDirectory() + filename;
}
if(GetFileAttributesA(filename.c_str())== INVALID_FILE_ATTRIBUTES)
throw std::exception("MTConnectDeviceParser::ReadDeviceDescription invalid devices file");
_devicesfilename = filename;
try{
ParseXMLDocument(_devicesfilename.c_str());
MSXML2::IXMLDOMNodePtr root = m_pXMLDoc->GetdocumentElement();
MSXML2::IXMLDOMNodeListPtr nodes = root->selectNodes(_bstr_t("//DataItem"));
for(int i=0; i< nodes->length; i++)
{
MSXML2::IXMLDOMNodePtr pNode = NULL;
CDataItem dataItem;
nodes->get_item(i, &pNode);
dataItem.name = (LPCSTR) GetAttribute(pNode, "name");
dataItem.category = (LPCSTR) GetAttribute(pNode, "category");
dataItem.id = (LPCSTR) GetAttribute(pNode, "id");
dataItem.type = (LPCSTR) GetAttribute(pNode, "type");
dataItem.subType = (LPCSTR) GetAttribute(pNode, "subType");
dataItem.units = (LPCSTR) GetAttribute(pNode, "units");
dataItem.nativeUnits = (LPCSTR) GetAttribute(pNode, "nativeUnits");
if(dataItem.type == "ASSET_CHANGED")
{
dataItem.category = "ASSET_CHANGED";
}
dataItem.category=MakeLower(dataItem.category);
if(!dataItem.name.empty())
{
dataItems[dataItem.name]=dataItem;
}
// Could get name or id via SHDR
else if(!dataItem.id.empty())
{
dataItems[dataItem.id]=dataItem;
}
else
{
continue;
}
}
}
catch(_com_error error)
{
std::cout << "MTConnectDeviceParser::ReadDeviceDescription" << error.ErrorMessage();
}
return dataItems;
}
示例4: FetchNodeList
//遍历指定节点列表的数据
BOOL CXmlBase::FetchNodeList(LPCTSTR lpszXmlPathFile, LPCTSTR lpszNamespace
, LPCTSTR lpszNodeListXPath, DWORD dwFlag)
{
MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
MSXML2::IXMLDOMNodeListPtr pNodeList = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
long lNodeCount = 0;
HRESULT hr = S_OK;
if (!IsAccessibleFile(lpszXmlPathFile)) return FALSE;
pDoc = GetXmlDocPtrByFile(lpszXmlPathFile, lpszNamespace);
if (pDoc == NULL) return FALSE;
pNodeList = GetNodeListPtr(lpszNodeListXPath, pDoc);
if (pNodeList == NULL) return FALSE;
lNodeCount = pNodeList->Getlength();
for (int i=0; i<lNodeCount; i++)
{
hr = pNodeList->get_item(i, &pNode);
if (FAILED(hr) || NULL == pNode) return FALSE;
if (!OnFetchNodeList(pNode, dwFlag)) return FALSE;
}
return TRUE;//(lNodeCount != 0);
}
示例5: nLoadTestCases
/******************************************************************************
Function Name : nLoadTestCases
Input(s) : MSXML2::IXMLDOMNodePtr& pTSDOM
Output : INT
Functionality :
Member of : CTestSetupEntity
Friend of : -
Author(s) : Venkatanarayana Makam, GT-Derka
Date Created : 06/04/2011
Modifications :
Codetag : CS004
******************************************************************************/
INT CTestSetupEntity::nLoadTestCases(MSXML2::IXMLDOMNodePtr& pTSDOM)
{
LONG lDefaultChannelUsed = 0;
LONG lCount;
_bstr_t bstrNodeName(def_STR_TESTCASE_NODE);
MSXML2::IXMLDOMNodeListPtr pDOMTCNodeList;
MSXML2::IXMLDOMNodePtr pIXMLDOMTestCase;
pDOMTCNodeList = pTSDOM->selectNodes(bstrNodeName);
pDOMTCNodeList->get_length(&lCount);
for(int i=0; i<lCount; i++)
{
CTestCaseEntity odTestCaseEntity;
pIXMLDOMTestCase = pDOMTCNodeList->Getitem(i);
odTestCaseEntity.GetData(pIXMLDOMTestCase);
m_odTestCaseEntityList.AddTail(odTestCaseEntity);
lDefaultChannelUsed += odTestCaseEntity.m_lDefaultChannelUsed;
}
if(lDefaultChannelUsed == 1)
{
AfxMessageBox(_("1 entity without channel-information loaded.\nCAN-Channel 1 selected."), MB_OK | MB_ICONINFORMATION );
}
else if(lDefaultChannelUsed > 1)
{
CString str;
str.Format("%d", lDefaultChannelUsed);
AfxMessageBox(str + _(" entities without channel-information loaded.\nCAN-Channel 1 selected in each case."), MB_OK | MB_ICONINFORMATION );
}
return S_OK;
}
示例6: readVerticesNormalsTexcoords
void readVerticesNormalsTexcoords(MSXML2::IXMLDOMNodePtr mesh, geometry_t &geometry)
{
MSXML2::IXMLDOMNodeListPtr sourceList = mesh->selectNodes("r:source");
vector<float> vertices;
vector<float> normals;
vector<float> texcoords;
for (int i = 0; i < sourceList->length; i++)
{
MSXML2::IXMLDOMNodePtr source = sourceList->Getitem(i);
MSXML2::IXMLDOMNamedNodeMapPtr attributes = source->attributes;
for (int j = 0; j < attributes->length; j++)
{
_bstr_t attributeName = attributes->getNamedItem("id")->text;
if (wcsstr(_wcslwr(attributeName), L"position"))
{
geometry.vertices = readArray<float>(source);
} else if (wcsstr(_wcslwr(attributeName), L"normal"))
{
geometry.normals = readArray<float>(source);
} else if (wcsstr(_wcslwr(attributeName), L"map") || // belnder
wcsstr(_wcslwr(attributeName), L"-uv")) // 3dsmax
{
geometry.texcoords = readArray<float>(source);
}
}
}
}
示例7:
int CXMLParser3::GetNodeText_len(LPCTSTR strNodeName,TCHAR *pDestBuffer,int nNode/*=0*/)
{
try
{
HRESULT hr;
MSXML2::IXMLDOMNodeListPtr List = m_pXMLDom->getElementsByTagName((_bstr_t)strNodeName);
long lNodesCount = 0;
hr = List->get_length(&lNodesCount);
if(SUCCEEDED(hr) && (nNode<lNodesCount ))
{
MSXML2::IXMLDOMNodePtr Node = List->item[nNode];
int nLen = _tcslen(Node->text);
if(pDestBuffer==NULL)
{
pDestBuffer = new TCHAR[nLen+1];
}
_tcscpy(pDestBuffer,Node->text);
pDestBuffer[nLen+1]='\0';
return nLen;
}
return 0;
}
catch (_com_error &e)
{
m_nError = e.Error();
m_strError = e.ErrorMessage();
return 0;
}
catch (...)
{
}
return 0;
}
示例8: Parse
void XmlParser::Parse(NodeCallback callback, void *data)
{
MSXML2::IXMLDOMNodeListPtr NodeListPtr;
BSTR strFindText = L" ";
MSXML2::IXMLDOMNode *pIDOMNode = NULL;
BSTR bstrNodeType;
assert(m_domDocument != NULL);
NodeListPtr = m_domDocument->getElementsByTagName(strFindText);
for(int i = 0; i < NodeListPtr->length; i++)
{
if (pIDOMNode)
pIDOMNode->Release();
NodeListPtr->get_item(i, &pIDOMNode);
pIDOMNode->get_nodeTypeString(&bstrNodeType);
if (lstrcmp((LPCTSTR)bstrNodeType, (LPCTSTR)L"element") != 0)
continue;
XmlNode node;
_parseNode(pIDOMNode, node);
if (callback(node, data) == false)
break;
}
if (pIDOMNode)
pIDOMNode->Release();
}
示例9: msiInstall
CA_API UINT __stdcall LocalGroupMembers_Deferred(MSIHANDLE hInstall)
{
MSI_EXCEPTION_HANDLER_PROLOG;
MsiInstall msiInstall(hInstall);
AppSecInc::Xml::XmlDocument xmlDocument;
xmlDocument.LoadXml(msiInstall.GetActionData());
MSXML2::IXMLDOMNodeListPtr rows = xmlDocument.SelectNodes(L"/LocalGroupMembers/LocalGroupMember");
MSXML2::IXMLDOMNodePtr row = NULL;
while (NULL != (row = rows->nextNode()))
{
std::wstring id = xmlDocument.GetAttributeValue(L"id", row);
std::wstring username = xmlDocument.GetNodeValue(L"Username", row);
std::wstring groupname = xmlDocument.GetNodeValue(L"Group", row, L"");
bool add_member = xmlDocument.GetAttributeBoolValue(L"add", row);
bool remove_member = xmlDocument.GetAttributeBoolValue(L"remove", row);
bool check = xmlDocument.GetAttributeBoolValue(L"check", row);
if (remove_member && (! check || AppSecInc::LSA::LocalGroup::IsMember(groupname, username)))
{
msiInstall.LogInfo(_T(__FUNCTION__), L"Removing \"" + username + L"\" from \"" + groupname + L"\"");
AppSecInc::LSA::LocalGroup::DeleteMember(groupname, username);
}
if (add_member && (! check || ! AppSecInc::LSA::LocalGroup::IsMember(groupname, username)))
{
msiInstall.LogInfo(_T(__FUNCTION__), L"Adding \"" + username + L"\" to \"" + groupname + L"\"");
AppSecInc::LSA::LocalGroup::AddMember(groupname, username);
}
}
MSI_EXCEPTION_HANDLER_EPILOG;
return ERROR_SUCCESS;
}
示例10: GetNodeListPtr
//遍历指定节点列表的数据
BOOL CXmlBase::FetchNodeList2(MSXML2::IXMLDOMNodePtr pParentNode, DWORD dwFlag)
{
MSXML2::IXMLDOMNodeListPtr pNodeList = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
long lNodeCount = 0;
HRESULT hr = S_OK;
if (NULL == pParentNode)
{
return FALSE;
}
pNodeList = GetNodeListPtr(pParentNode);
if (pNodeList == NULL)
{
return FALSE;
}
lNodeCount = pNodeList->Getlength();
for (long i=0; i<lNodeCount; i++)
{
hr = pNodeList->get_item(i, &pNode);
if (FAILED(hr) || NULL == pNode)
{
return FALSE;
}
if (!OnFetchNodeList2(pNode, dwFlag))
{
return FALSE;
}
}
return TRUE;
}
示例11: GetLastElementChild
// 获取当前节点的最后一个Element子节点
IBpXMLNode* CBpXMLNode::GetLastElementChild() const
{
if (m_pDOMNode == NULL)
return NULL;
if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList == NULL)
return NULL;
long nListLen = 0;
pNodeList->get_length(&nListLen);;
MSXML2::IXMLDOMNodePtr pNode = NULL;
for (long i = 0; i < nListLen; i++)
{
pNodeList->get_item(nListLen - 1 - i, &pNode);
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
CBpXMLNode *pNodeCreated = new CBpXMLNode();
pNodeCreated->m_pDOMNode = pNode;
return (IBpXMLNode*)pNodeCreated;
}
}
}
return NULL;
}
示例12: msiInstall
CA_API UINT __stdcall TemplateFiles_Deferred(MSIHANDLE hInstall)
{
MSI_EXCEPTION_HANDLER_PROLOG;
MsiInstall msiInstall(hInstall);
AppSecInc::Xml::XmlDocument xmlDocument;
xmlDocument.LoadXml(msiInstall.GetActionData());
MSXML2::IXMLDOMNodeListPtr rows = xmlDocument.SelectNodes(L"//TemplateFile[@execute='true']"); // \todo //Row[@rollback='false']
MSXML2::IXMLDOMNodePtr row = NULL;
while (NULL != (row = rows->nextNode()))
{
std::wstring id = xmlDocument.GetAttributeValue(L"id", row);
std::wstring source = xmlDocument.GetNodeValue(L"Source", row);
std::wstring target = xmlDocument.GetNodeValue(L"Target", row, source);
msiInstall.LogInfo(L"TemplateFiles_Deferred", source + L" => " + target);
std::map<std::wstring, std::wstring> properties;
{
MSXML2::IXMLDOMNodeListPtr property_rows = xmlDocument.SelectNodes(L"Properties/Property", row);
MSXML2::IXMLDOMNodePtr property_row = NULL;
while (NULL != (property_row = property_rows->nextNode()))
{
std::wstring name = xmlDocument.GetAttributeValue(L"name", property_row);
std::wstring value = xmlDocument.GetAttributeValue(L"value", property_row);
long escape = AppSecInc::StringUtils::stringToLong(xmlDocument.GetAttributeValue(L"escape", property_row, L"0"));
properties[name] = escape == 1 ? AppSecInc::StringUtils::escape(value) : value;
}
}
std::wstring data;
bool utf8 = AppSecInc::File::ReadAndConvertToEnd(source, data);
data = AppSecInc::Formatter::FormatTemplate(data, properties);
std::string char_data;
if (utf8)
{
char_data = AppSecInc::StringUtils::wc2utf8(data);
char_data.insert(0, std::string(reinterpret_cast<char *>(AppSecInc::File::utf8_bom)));
}
else
{
char_data = AppSecInc::StringUtils::wc2mb(data);
}
std::vector<char> binary_data;
binary_data.assign(char_data.begin(), char_data.end());
AppSecInc::File::FileWrite(target, binary_data);
}
MSI_EXCEPTION_HANDLER_EPILOG;
return ERROR_SUCCESS;
}
示例13: SetNodeValue
//设置指定xpath的节点值
BOOL CXmlBase::SetNodeValue(LPCTSTR lpszValue, LPCTSTR lpszXPath
, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
if (pDoc == NULL || lpszXPath == NULL) return FALSE;
MSXML2::IXMLDOMNodeListPtr pNodeList = pDoc->selectNodes(lpszXPath);
long lCnt = pNodeList->Getlength();
if (lCnt == 0) return FALSE;
MSXML2::IXMLDOMNodePtr pNode = pNodeList->Getitem(0);
return SetNodeValue(lpszValue, pNode);
}
示例14: PickUpGroups
BOOL CIconImgList::PickUpGroups( MSXML2::IXMLDOMElementPtr& piGroup, int& nIndex)
{
MSXML2::IXMLDOMNodeListPtr piGroupList;
piGroupList = piGroup->GetchildNodes();
MSXML2::IXMLDOMElementPtr piNode;
MSXML2::IXMLDOMElementPtr piChild;
int nParent = nIndex;
_bstr_t cBstr;
_variant_t cVariant;
long lCount = piGroupList->Getlength();
for( long lIndex = 0; lIndex < lCount; lIndex++)
{
piNode = piGroupList->Getitem( lIndex);
if( _bstr_t( _T( "GROUP")) == piNode->GetbaseName())
{
cBstr = piNode->getAttribute( _bstr_t( _T( "TITLE")));
cVariant = piNode->getAttribute( _bstr_t( _T( "ENABLE")));
cVariant.ChangeType( VT_BOOL);
m_astGroupData[ nIndex] = ( GROUPDATA*)malloc( sizeof( GROUPDATA) + ( sizeof( TCHAR) * ( cBstr.length() + 1)));
m_astGroupData[ nIndex]->nParent = nParent;
if( 1 <= nIndex)
{
if( FALSE == m_astGroupData[ nParent]->blEnable)
{
cVariant.boolVal = VARIANT_FALSE;
}
}
m_astGroupData[ nIndex]->blEnable = ( VARIANT_FALSE == cVariant.boolVal) ? FALSE : TRUE;
lstrcpy( m_astGroupData[ nIndex]->szName, cBstr);
nIndex++;
PickUpGroups( piNode, nIndex);
}
else if( _bstr_t( _T( "ITEM")) == piNode->GetbaseName())
{
cVariant = piNode->getAttribute( _bstr_t( _T( "REF")));
cVariant.ChangeType( VT_I4);
for( int nIndex = 0; nIndex < m_nEnableCount; nIndex++)
{
if( cVariant.intVal == ( m_astIconStatus[ nIndex].nID + 1))
{
m_astIconStatus[ nIndex].nParent = nParent;
}
}
}
}
return TRUE;
}
示例15: GetCommonVerifyData
/******************************************************************************
Function Name : GetData
Input(s) :
Output : HRESULT
Functionality :
Member of : CVerifyEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
******************************************************************************/
HRESULT CVerifyEntity::GetCommonVerifyData(MSXML2::IXMLDOMNodePtr& pIDomNode, CVerifyData *verifyData)
{
m_ouData = verifyData;
_bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
CComVariant NodeValue;
MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
MSXML2::IXMLDOMNodePtr pIDOMChildNode;
pDOMVerifyAtrributes = pIDomNode->Getattributes();
//bstrNodeName = L"failure";
bstrNodeName.Assign(SysAllocString(CT2W("failure")));
pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
pIDOMChildNode->get_nodeTypedValue(&NodeValue);
CString strTemp;
strTemp = strCopyBSTRToCString(NodeValue);
//m_ouData = new CVerifyData();
if(strTemp == "SUCCESS")
{
m_ouData->m_eAttributeError = SUCCESS;
}
else if(strTemp == "WARNING")
{
m_ouData->m_eAttributeError = WARNING;
}
else if(strTemp == "ERRORS")
{
m_ouData->m_eAttributeError = ERRORS;
}
else
{
m_ouData->m_eAttributeError = FATAL;
}
MSXML2::IXMLDOMNodeListPtr pIDOMSendList;
LONG lCount;
//bstrNodeName = def_STR_VERIFYMSG_NODE;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VERIFYMSG_NODE)));
pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
pIDOMSendList->get_length(&lCount);
for(int i = 0; i < lCount; i++)
{
CVerifySubEntity *odVerifySubEntity;
MSXML2::IXMLDOMNodePtr pIXMLDOMVerifyMsgEntity;
pIXMLDOMVerifyMsgEntity = pIDOMSendList->Getitem(i);
//if(CVerifySubEntity::GetData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
if(this->GetSubEntityData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
{
m_ouData->m_odVerifySubEntityList.push_back(odVerifySubEntity);
}
}
return S_OK;
}