本文整理汇总了C++中msxml2::IXMLDOMNodePtr类的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNodePtr类的具体用法?C++ IXMLDOMNodePtr怎么用?C++ IXMLDOMNodePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IXMLDOMNodePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readObject
BOOL WXmlParse::readObject(std::vector<ExternalObject *> &objTree)
{
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(3, &xmlNode);
xmlNode->get_childNodes(&subElementNodes);
subElementNodes->get_length(&subLength);
for (int j = 0; j < subLength;j++)
{
ExternalObject *objTmp = new ExternalObject();
subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
xmlSubNode->get_attributes(&elementAttributes);
readObject(objTmp, xmlSubNode);
objTree.push_back(objTmp);
}
return TRUE;
}
示例2: ReplaceNode
bool XmlParser::ReplaceNode(XmlNode nodeNew, XmlNode nodeOld)
{
MSXML2::IXMLDOMNodePtr pParentNode;
nodeOld.GetIXMLDOMElementPtr()->get_parentNode(&pParentNode);
return SUCCEEDED(pParentNode->replaceChild(nodeNew.GetIXMLDOMElementPtr(), nodeOld.GetIXMLDOMElementPtr()));
}
示例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: 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;
}
示例5: 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();
}
示例6: GetCount
//-------------------------------------------------------------------------
// Function Name :GetCount
// Parameter(s) :void
// Return :LONG
// Memo :
//-------------------------------------------------------------------------
LONG CXmlNodes::GetCount(void)
{
ASSERT( m_pNodeList != NULL );
LONG lCount = 0l;
HRESULT hr = S_OK;
MSXML2::DOMNodeType NodeType;
MSXML2::IXMLDOMNodePtr pNode = NULL;
for( int i = 0; i < m_pNodeList->length; i++)
{
pNode = m_pNodeList->item[i];
hr = pNode->get_nodeType(&NodeType);
ASSERT( SUCCEEDED(hr) );
if( NodeType == MSXML2::NODE_ELEMENT )
{
lCount ++;
}
SAFE_RELEASE(pNode);
}
return lCount;
}
示例7: 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;
}
示例8: GetFileFormatVersion
void Translator::GetFileFormatVersion(std::string &fileFormatVersion, InputStream *readStream, TSError *error, char *errorMsg, long maxErrorMsgLengthInBytes)
{
readStream->Offset = 0;
GetParser()->LoadFile(readStream);
MSXML2::IXMLDOMNodePtr header = GetParser()->GetHeader(readStream);
fileFormatVersion = header->Getattributes()->getNamedItem("fileformatversion")->text;
}
示例9: GetTextForSmartTagName
CStdString SmartTagParser::GetTextForSmartTagName(const CStdString & SmartTagName)
{
if (m_spXMLDom == NULL)
{
CStdString msg;
msg.Format(_T("SmartTagParser::GetTextForSmartTagName - The XML document pointer is null."));
throw Workshare::NullReferenceException(msg);
}
CComBSTR nodeText = _T("//");
nodeText += GetNamespacePrefix();
nodeText += _T(":");
nodeText += SmartTagName;
MSXML2::IXMLDOMNodePtr pNode = m_spXMLDom->selectSingleNode(nodeText.m_str);
if (pNode == NULL)
{
CStdString msg;
msg.Format(_T("SmartTagParser::GetTextForSmartTagName - Failed to get node (%s) from the XML"), nodeText);
throw Workshare::Exception(msg);
}
CStdString sValue = pNode->text;
if (pNode)
{
pNode.Release();
}
return sValue;
}
示例10: 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;
}
示例11: 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;
}
示例12: IsPropertyElement
bool PropertyElement::IsPropertyElement(MSXML2::IXMLDOMNodePtr pNode)
{
MSXML2::IXMLDOMNodePtr pNameElement = pNode->selectSingleNode(bstr_t(L"Name"));
MSXML2::IXMLDOMNodePtr pValueElement = pNode->selectSingleNode(bstr_t(L"Value"));
if(pNameElement!=NULL && pValueElement !=NULL)
return true;
return false;
}
示例13: InsertEnterAndTabs
MSXML2::IXMLDOMNodePtr CXmlBase::InsertEnterAndTabs(MSXML2::IXMLDOMNodePtr pParentNode, MSXML2::IXMLDOMNodePtr pNode, int nLevel)
{
HRESULT hr = S_OK;
MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
MSXML2::IXMLDOMTextPtr pTabsText = NULL;
MSXML2::IXMLDOMNodePtr pTabsNode = NULL;
MSXML2::IXMLDOMElementPtr pElement = NULL;
CString strText(_T("")), strTabs(_T(""));
CComBSTR bstrText;
if (nLevel < 0
|| pParentNode == NULL) return NULL;
if(pNode == NULL)nLevel = 0;
for (int i=0; i<nLevel; i++)
{
strTabs += _T("\t");
}
strText.Format(_T("%s%s"), _T("\r\n"), (LPCTSTR)strTabs);
bstrText = _bstr_t(strText).GetBSTR();
try
{
pDoc = pParentNode->GetownerDocument();
if (pDoc == NULL) return NULL;
pTabsText = pDoc->createTextNode((LPCTSTR)strText);
if (pTabsText == NULL) return NULL;
CComVariant varNode = pNode.GetInterfacePtr();
pTabsNode = pParentNode->insertBefore(pTabsText, varNode);
//hr = pDoc->raw_createTextNode(bstrText.m_str, &pTabsText);
//if (FAILED(hr) || pTabsText == NULL) return NULL;
//pElement = pTabsText;
//pTabsNode = pParentNode->appendChild(pElement);
//pTabsNode = pDoc->createTextNode((LPCTSTR)strText);
//if (pTabsNode == NULL) return NULL;
//pNode = pNode->appendChild(pTabsNode);
}
catch(_com_error &e)
{
CString str;
str.Format(_T("创建xml节点发生异常。\r\nComError:\r\n%s")
, e.ErrorMessage());
::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
return NULL;
}
catch(...)
{
return NULL;
}
return pTabsNode;
}
示例14: 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();
}
示例15: InsertAfter
MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, MSXML2::IXMLDOMNode *pNode)
{
MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling();
MSXML2::IXMLDOMNodePtr newNode;
if (nextNode.GetInterfacePtr() != NULL)
newNode = m_xmlnode->insertBefore(pNode,(IUnknown*)nextNode);
else
newNode = m_xmlnode->appendChild(pNode);
return newNode.Detach();
}