本文整理汇总了C++中msxml2::IXMLDOMNamedNodeMapPtr类的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNamedNodeMapPtr类的具体用法?C++ IXMLDOMNamedNodeMapPtr怎么用?C++ IXMLDOMNamedNodeMapPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IXMLDOMNamedNodeMapPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nParseTSFile
/******************************************************************************
Function Name : nParseTSFile
Input(s) : CString omstrTSFile
Output : INT
Functionality : Load the omStrTSFille
Member of : CTestSetupEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
Codetag : CS002
******************************************************************************/
INT CTestSetupEntity::nParseTSFile(CString omstrTSFile)
{
MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
if ( FAILED(hr) )
{
throw "Unable to create XML parser object";
}
if(PathFileExists(omstrTSFile) == FALSE)
{
return ERR_PATH_INCORRECT;
}
//Create A TestSetup DOM document
CComVariant varFileName((LPCSTR)omstrTSFile);
try
{
pIDOMDoc->load(varFileName);
//GetTest Setup Title
MSXML2::IXMLDOMNodePtr pIDOMTiltleNode;
_bstr_t bstrNodeName = def_STR_TSNODE_NAME;
CComVariant NodeValue;
pIDOMTiltleNode = pIDOMDoc->selectSingleNode(bstrNodeName);
MSXML2::IXMLDOMNamedNodeMapPtr pDOMTCAtrributes;
pDOMTCAtrributes = pIDOMTiltleNode->Getattributes();
MSXML2::IXMLDOMNodePtr pIDOMChildNode;
//bstrNodeName = def_STR_TSATTRIB_TITLE;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSATTRIB_TITLE)));
pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
pIDOMChildNode->get_nodeTypedValue(&NodeValue);
m_omstrTestSetupTitle = strCopyBSTRToCString(NodeValue);
pIDOMChildNode.Release();
//Get Description
//bstrNodeName = def_STR_TSDESCRIPTION;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSDESCRIPTION)));
MSXML2::IXMLDOMNodePtr pIDOMDescriptionNode = pIDOMDoc->selectSingleNode(bstrNodeName);
pIDOMDescriptionNode->get_nodeTypedValue(&NodeValue);
m_omstrDescription = strCopyBSTRToCString(NodeValue);
//Get Header Node
//bstrNodeName = def_STR_TSHEADER;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSHEADER)));
MSXML2::IXMLDOMNodePtr pIDOMHeaderNode = pIDOMDoc->selectSingleNode(bstrNodeName);
nLoadHeader(pIDOMHeaderNode);
pIDOMHeaderNode.Release();
//Get TestCases List
//bstrNodeName = def_STR_TSTCLIST;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSTCLIST)));
MSXML2::IXMLDOMNodePtr pIDOMTSNode = pIDOMDoc->selectSingleNode(bstrNodeName);
GetData(pIDOMTSNode);
}
catch(...)
{
return S_FALSE;
}
return S_OK;
}
示例2: 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);
}
}
}
}
示例3: readExtendModName
BOOL WXmlParse::readExtendModName(std::vector<std::pair<string, string> > &modNames)
{
MSXML2::IXMLDOMDocumentPtr doc;
MSXML2::IXMLDOMElementPtr docRoot;
MSXML2::IXMLDOMElementPtr docElement;
MSXML2::IXMLDOMNodeListPtr elementNodes;
MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
MSXML2::IXMLDOMNodePtr xmlNode;
MSXML2::IXMLDOMNodePtr xmlSubNode;
MSXML2::IXMLDOMNodePtr xmlAttrNode;
doc.CreateInstance(__uuidof(DOMDocument30));
doc->load((_variant_t)m_strFileName);
docRoot = doc->GetdocumentElement();//获得根节点;
docRoot->get_childNodes(&elementNodes);
LONG length, subLength, attrLength;
elementNodes->get_length(&length);
MSXML2::IXMLDOMNodeListPtr subElementNodes;
// 3 : 扩展模块列表
elementNodes->get_item(1, &xmlNode);
xmlNode->get_childNodes(&subElementNodes);
subElementNodes->get_length(&subLength);
for (int j = 0; j < subLength;j++)
{
subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
xmlSubNode->get_attributes(&elementAttributes);
MSXML2::IXMLDOMNodePtr nameNode = elementAttributes->getNamedItem("name");
MSXML2::IXMLDOMNodePtr descNode = elementAttributes->getNamedItem("description");
modNames.push_back(std::make_pair(nameNode->text, descNode->text));
}
return TRUE;
}
示例4: GetData
/******************************************************************************
Function Name : GetData
Input(s) :
Output : HRESULT
Functionality :
Member of : CVerifyResponse
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
******************************************************************************/
HRESULT CVerifyResponse::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
CVerifyEntity::GetData(pIDomNode);
_bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
CComVariant NodeValue;
MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
MSXML2::IXMLDOMNodePtr pIDOMChildNode;
pDOMVerifyAtrributes = pIDomNode->Getattributes();
//bstrNodeName = def_STR_ATTRIB_WAITFOR;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_ATTRIB_WAITFOR)));
pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
pIDOMChildNode->get_nodeTypedValue(&NodeValue);
CString strTemp;
strTemp = strCopyBSTRToCString(NodeValue);
//W4 Removal
m_ushDuration = (USHORT)atoi((LPCSTR)strTemp);
INT nCount = (INT)m_ouData.m_odVerify_MessageEntityList.GetCount();
for(int i = 0; i < nCount; i++)
{
CVerify_MessageData ouVerifyData;
POSITION pos = m_ouData.m_odVerify_MessageEntityList.FindIndex(i);
CVerify_MessageEntity& ouVerifyEntity = m_ouData.m_odVerify_MessageEntityList.GetAt(pos);
ouVerifyEntity.GetEntityData(VERIFY_MESSAGE, &ouVerifyData);
m_ouVerifyMsgMap[ouVerifyData.m_dwMessageID] = ouVerifyData;
}
return S_OK;
}
示例5: WalkTree
////////////////////////////////////////////////////////////////////////////
// Helper function: Walk all the Elements at a particular node
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(int iLevel, MSXML2::IXMLDOMNode* pNode)
{
HRESULT hr = S_OK;
CComBSTR bstrNodeName;
pNode->get_nodeName(&bstrNodeName);
CComVariant vNodeValue;
pNode->get_nodeValue(&vNodeValue);
vNodeValue.ChangeType(VT_BSTR);
CString strValueString = V_BSTR(&vNodeValue);
if (m_pCallbackFunction)
m_pCallbackFunction(iLevel, CString(bstrNodeName), (LPCSTR)NULL, strValueString, m_pCallbackParam);
MSXML2::IXMLDOMNamedNodeMapPtr pAttributes = NULL;
if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
{
MSXML2::IXMLDOMNodePtr pAttribute = NULL;
pAttributes->nextNode(&pAttribute);
bool bRetVal = true;
while (pAttribute)
{
CComBSTR bstrAttribName;
pAttribute->get_nodeName(&bstrAttribName);
CComVariant vNodeValue;
pAttribute->get_nodeValue(&vNodeValue);
vNodeValue.ChangeType(VT_BSTR);
CString strValueString = V_BSTR(&vNodeValue);
if (m_pCallbackFunction)
bRetVal = m_pCallbackFunction(iLevel+1, CString(bstrNodeName), CString(bstrAttribName), strValueString, m_pCallbackParam);
if (!bRetVal)
{
// set complete error message with node name and all attribute values
m_strErrorNode = bstrNodeName;
return S_FALSE;
}
pAttributes->nextNode(&pAttribute);
}
}
MSXML2::IXMLDOMNodePtr pChild = NULL;
pNode->get_firstChild(&pChild);
while (pChild)
{
if (WalkTree(iLevel+1, pChild) != S_OK)
return S_FALSE;
MSXML2::IXMLDOMNode* pNext = NULL;
pChild->get_nextSibling(&pNext);
pChild = pNext;
}
return S_OK;
}
示例6: hodeHasAttribute
bool hodeHasAttribute(MSXML2::IXMLDOMNodePtr& node,
const String& attributeName, const String attributeNameSpace) {
MSXML2::IXMLDOMNamedNodeMapPtr attributes = node->Getattributes();
MSXML2::IXMLDOMNodePtr res = attributes->getQualifiedItem(attributeName.c_str(),
attributeNameSpace.c_str());
return res != NULL;
}
示例7: GetNamespacePrefix
CStdString SmartTagParser::GetNamespacePrefix()
{
if (m_spXMLDom == NULL)
{
CStdString msg;
msg.Format(_T("SmartTagParser::GetNamespacePrefix - The XML document pointer is null."));
throw Workshare::NullReferenceException(msg);
}
MSXML2::IXMLDOMElementPtr spElement = m_spXMLDom->firstChild;
if (spElement == NULL)
{
CStdString msg;
msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get the first node of the document."));
throw Workshare::Exception(msg);
}
MSXML2::IXMLDOMNamedNodeMapPtr spAttributes = spElement->attributes;
if (spAttributes == NULL)
{
spElement.Release();
CStdString msg;
msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get attributes of the first child of the document."));
throw Workshare::Exception(msg);
}
MSXML2::IXMLDOMAttributePtr spAttribute = spAttributes->item[0];
if (spAttribute == NULL)
{
spElement.Release();
spAttributes.Release();
CStdString msg;
msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get attributes of the first child of the document."));
throw Workshare::Exception(msg);
}
CStdString sFullNamespace = spAttribute->xml;
HRESULT hr = m_spXMLDom->raw_setProperty(_T("SelectionNamespaces"), _variant_t(sFullNamespace.c_str()));
if (FAILED(hr))
{
CStdString message;
message.Format(_T("SmartTagParser::SmartTagParser - Failed to set namespace : %s."), sFullNamespace.c_str());
throw Workshare::Com::ComException(message.c_str(), hr, m_spXMLDom);
}
int iPosStart = sFullNamespace.Find(_T(":"));
int iPosEnd = sFullNamespace.Find(_T("="));
CStdString sPrefix = sFullNamespace.Mid(iPosStart+1, iPosEnd - (iPosStart+1));
spElement.Release();
spAttributes.Release();
spAttribute.Release();
return sPrefix;
}
示例8: GetAttrsOfNode
int CXmlBase::GetAttrsOfNode(map<CString, CComBSTR>& mapAttrs, MSXML2::IXMLDOMNodePtr pNode)
{
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs;
MSXML2::IXMLDOMNodePtr pAttr;
HRESULT hr;
CComBSTR bstrText;
CString str;
long lAttrCount = 0;
mapAttrs.clear();
if (NULL == pNode)
{
//WRITELOG("END, pNode为空");
return 0;
}
pAttrs = pNode->Getattributes();
if (pAttrs == NULL)
{
//WRITELOG("END, 取得节点属性集合失败");
return 0;
}
lAttrCount = pAttrs->Getlength();
for (int i=0; i<lAttrCount; i++)
{
pAttr = pAttrs->Getitem(i);
if (pAttr == NULL)
{
//WRITELOG("取得第[%d]个属性为空", i);
continue;
}
hr = pAttr->get_nodeName(&bstrText);
if (FAILED(hr))
{
//WRITELOG("取得第[%d]个属性名为空", i);
continue;
}
if (!ConvertBSTR2CString(str, bstrText.m_str))
{
//WRITELOG("转换第[%d]个属性名 失败", i);
continue;
}
hr = pAttr->get_text(&bstrText);
if (FAILED(hr))
{
//WRITELOG("取得第[%d]个属性值 失败,属性[%s]", i, str);
continue;
}
mapAttrs.insert(make_pair(str, bstrText));
}
return (int)mapAttrs.size();
}
示例9: hasAttributes
bool XMLElement::hasAttributes() const {
bool found = false;
MSXML2::IXMLDOMNamedNodeMapPtr attrs;
if (nodePtr) {
if ((nodePtr->get_attributes(&attrs)) == S_OK) {
if (attrs->Getlength() > 0) found = true;
}
}
return found;
}
示例10: readCalculateParams
BOOL WXmlParse::readCalculateParams(WCalcaulateParam &calParam)
{
MSXML2::IXMLDOMDocumentPtr doc;
MSXML2::IXMLDOMElementPtr docRoot;
MSXML2::IXMLDOMElementPtr docElement;
MSXML2::IXMLDOMNodeListPtr elementNodes;
MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
MSXML2::IXMLDOMNodePtr xmlNode;
MSXML2::IXMLDOMNodePtr xmlSubNode;
MSXML2::IXMLDOMNodePtr xmlAttrNode;
doc.CreateInstance(__uuidof(DOMDocument30));
if (m_strFileName.IsEmpty())
{
return FALSE;
}
doc->load((_variant_t)m_strFileName);
docRoot = doc->GetdocumentElement();//获得根节点;
docRoot->get_childNodes(&elementNodes);
LONG length, subLength, attrLength;
elementNodes->get_length(&length);
MSXML2::IXMLDOMNodeListPtr subElementNodes;
// 0 :
elementNodes->get_item(2, &xmlNode);
xmlNode->get_childNodes(&subElementNodes);
subElementNodes->get_length(&subLength);
for (int j = 0; j < subLength;j++)
{
subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
xmlSubNode->get_attributes(&elementAttributes);
MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
string proName = proNode->text;
MSXML2::IXMLDOMNodeListPtr subAttrNodes;
xmlSubNode->get_childNodes(&subAttrNodes);
subAttrNodes->get_length(&attrLength);
// ASSERT(attrLength == 2);
MSXML2::IXMLDOMNodePtr descNode;
MSXML2::IXMLDOMNodePtr stateNode;
subAttrNodes->get_item(0, &descNode);
subAttrNodes->get_item(1, &stateNode);
std::vector<string> vecParam;
string descText = descNode->text;
string stateText = stateNode->text;
vecParam.push_back(proName);
vecParam.push_back(descText);
vecParam.push_back(stateText);
calParam.addParam(vecParam);
}
return TRUE;
}
示例11: NumAttributes
int CXmlNodeWrapper::NumAttributes()
{
if (IsValid())
{
MSXML2::IXMLDOMNamedNodeMapPtr attribs = m_xmlnode->Getattributes();
if (attribs)
return attribs->Getlength();
}
return 0;
}
示例12: 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;
}
示例13: getFirstAttribute
XMLAttribute XMLElement::getFirstAttribute() const {
XMLAttribute attr;
MSXML2::IXMLDOMNamedNodeMapPtr attrs;
if (nodePtr) {
if ((nodePtr->get_attributes(&attrs)) == S_OK) {
if (attrs->Getlength() > 0) {
attr.attrPtr = attrs->Getitem(0);
}
}
}
return attr;
}
示例14: GetStringValue
////////////////////////////////////////////////////////////////////////////
// Helper function:
////////////////////////////////////////////////////////////////////////////
CString CXMLDocument::GetStringValue(LPCSTR szAttrib, MSXML2::IXMLDOMNode* pNode)
{
CComBSTR bstrValue;
MSXML2::IXMLDOMNamedNodeMapPtr pAttributes;
MSXML2::IXMLDOMNodePtr pItemNode;
if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
pAttributes->getNamedItem(CComBSTR(szAttrib), &pItemNode);
if (pItemNode)
pItemNode->get_text(&bstrValue);
return CString(bstrValue);
}
示例15: addTextAttributeToNode
void addTextAttributeToNode(MSXML2::IXMLDOMDocumentPtr& xmlDoc,
MSXML2::IXMLDOMNodePtr& targetNode, const String& attributeName,
const String& attributeValue) {
MSXML2::IXMLDOMNodePtr attributeNode =
xmlDoc->createNode(NODE_ATTRIBUTE, attributeName.c_str(), _T(""));
setNodeText(attributeNode, attributeValue);
MSXML2::IXMLDOMNamedNodeMapPtr attributes = targetNode->Getattributes();
if (attributes == NULL) {
throw XMLUtils::ParseError();
}
attributes->setNamedItem(attributeNode);
}