本文整理汇总了C++中TiXmlDocument::NoChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::NoChildren方法的具体用法?C++ TiXmlDocument::NoChildren怎么用?C++ TiXmlDocument::NoChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDocument
的用法示例。
在下文中一共展示了TiXmlDocument::NoChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportXML
bool ConfigFile::ImportXML(std::string strXML)
{
TiXmlDocument doc;
//Load document from strXML using streams
std::istringstream strIStream;
strIStream.str(strXML);
strIStream >> doc;
if ( doc.NoChildren() )
{
std::cout << "Could not parse xml string. Error='" << doc.ErrorDesc() << "'. Using Default Data" << std::endl;
m_strLastError = doc.ErrorDesc();
//Use already loaded defaults
return false;
}
TiXmlNode* parent = 0;
TiXmlNode* child = 0;
TiXmlNode* tempChild = 0;
TiXmlElement* configElement = 0;
TiXmlElement* itemElement = 0;
TiXmlElement* tempElement = 0;
// Get the "configData" element.
parent = doc.FirstChild( m_strIdentifier.c_str() );
assert( parent );
configElement =parent->ToElement();
assert( configElement );
//Read all the configuration data
for( child = configElement->FirstChild(); child; child = child->NextSibling() )
{
itemElement = child->ToElement();
assert( itemElement );
//convert to uppercase
std::string strElement = itemElement->Value();
//replace underscore with whitespace
std::replace(strElement.begin(), strElement.end(), '_', ' ');
ConfigAttribute element;
element.strAttribute = strElement;
element.strValue = itemElement->Attribute( "value");
//Read the sub items from the file and store as an array
if(!itemElement->NoChildren() || element.strValue == "Array()")
{
element.bIsArray = true;
for( tempChild = itemElement->FirstChild(); tempChild; tempChild = tempChild->NextSibling() )
{
tempElement = tempChild->ToElement();
assert( tempElement );
element.listValues.push_back(tempElement->Attribute( "value"));
}
}
m_mapConfig[Uppercase(strElement)] = element;
}
return true;
return true;
}