Tinyxml 是一个非常小巧的XML操作类,使用标准C++ 书写,使用非常方便。需要的可以联系我,dangde@163.com.
TiXmlDocument xmldoc;
xmldoc.LoadFile(sPath.c_str(), TIXML_ENCODING_LEGACY);
TiXmlElement *root = xmldoc.RootElement();
TiXmlNode *xmlnode = root->FirstChild("StdField");
TiXmlNode *pnode = xmlnode->FirstChild();
for (int i = 0; pnode; i++)
{
try
{
string sKey;
string sValue;
if (!pnode->ToElement()->Attribute("ID") || !pnode->ToElement()->Attribute("Name"))
{
cout << "TDataDict error: build standard field map,check xml file standard field index: " << i << endl;
}
else
{
sKey = pnode->ToElement()->Attribute("Name");
sValue = string(pnode->ToElement()->Attribute("ID"));
StdField.insert(pair<string,int>(sKey, atoi(sValue.c_str())));
}
}
catch(...)
{
//???
}
pnode = pnode->NextSibling();
}
浙公网安备 33010602011771号