示例#1
0
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
0
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;
}
示例#3
0
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;
}
示例#4
0
BOOL WXmlParse::readParam(std::vector<WParamDefine *> &outParams)
{
	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(0, &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;
		WParamDefine *paramTest = new WParamDefine(proName);
		MSXML2::IXMLDOMNodeListPtr subAttrNodes;  
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
		for (int k = 0;k < attrLength;k++)
		{
			subAttrNodes->get_item(k, &xmlAttrNode);
			string attrName = xmlAttrNode->nodeName;
			string attrText = xmlAttrNode->text;
			paramTest->addValue(attrName, attrText);
		}
		outParams.push_back(paramTest);
	}

	return TRUE;
}