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; }