Esempio n. 1
0
Result GetFirstElementByTagName(MSXML::IXMLDOMElementPtr& parent, const string& tagName, MSXML::IXMLDOMElementPtr& pEl)
{
	Result r;

	try
	{
		pEl = 0;
		MSXML::IXMLDOMNodeListPtr pList = parent->getElementsByTagName(tagName.c_str());
		if(pList == NULL)
		{
			r.Fail(Format("No '%' nodes found (pList = 0)").s(tagName).Str());
		}
		else
		{
			if(!pList->length)
			{
				r.Fail(Format("No '%' nodes found (length = 0)").s(tagName).Str());
			}
			else
			{
				pEl = pList->nextNode();
				r.Succeed();
			}
		}
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Com error: % %").s(e.ErrorMessage()).s(e.Description()).Str());
	}

	return r;
}
Esempio n. 2
0
void CSolarSystemDoc::ParseXmlDocument(MSXML::IXMLDOMDocumentPtr& pDocument)
{
	m_SolarSystem.m_Bodies.clear();

	{
		MSXML::IXMLDOMNodeListPtr pSolarSystem = pDocument->getElementsByTagName(L"SolarSystem");
		if (pSolarSystem)
		{
			pSolarSystem->reset();
			MSXML::IXMLDOMNodePtr pRecordNode = pSolarSystem->nextNode();
			m_Thread.m_timestep = static_cast<unsigned int>(GetXmlIntValue(pRecordNode, L"TimeStep", 300));
		}
	}

	MSXML::IXMLDOMNodeListPtr pRecordsList = pDocument->getElementsByTagName(L"Body");

	if (pRecordsList)
	{
		pRecordsList->reset();

		MSXML::IXMLDOMNodePtr pRecordNode = pRecordsList->nextNode();

		//for each group in the xml file
		while (pRecordNode)
		{
			m_SolarSystem.m_Bodies.emplace_back(MolecularDynamics::Body());
			m_SolarSystem.m_BodyProperties.emplace_back(BodyProperties());

			LoadBodyXml(pRecordNode, m_SolarSystem.m_Bodies.back(), m_SolarSystem.m_BodyProperties.back());
			
			pRecordNode = pRecordsList->nextNode();
		}
	}

	m_SolarSystem.m_Bodies.shrink_to_fit();
	m_SolarSystem.m_BodyProperties.shrink_to_fit();
}