void AnswerGenerator::SaveAnswer( AnswerList & answerList ) { XmlDocument xmlDoc; XmlNode * resNode = xmlDoc.AddNode( "resource" ); int count = answerList.size(); for( int num = 0; num < count; num++ ) { AnswerData & answer = answerList[ num ]; std::string ans = answer._answer; std::string ref = answer._reference; XmlNode * qsNode = resNode->AddNode( "question" ); char buf[8]; itoa(num, buf, 10); qsNode->SetAttribute( "no", buf ); XmlNode * referenceNode = qsNode->AddNode( "table" ); referenceNode->SetText( ref.c_str(), XmlNode::NUMBER ); XmlNode * answerNode = qsNode->AddNode( "answer" ); answerNode->SetText( ans.c_str(), XmlNode::NUMBER ); } std::string path = "./resource/ResultAnswer.xml"; xmlDoc.SaveFile( path.c_str() ); }
void DBDictionary::Init() { // 사전 초기화 _dic.clear(); // 사전 생성 옵션 로드 XmlDocument xmlDoc; std::string path = "./resource/DBDicConfig.xml"; xmlDoc.LoadFile( path.c_str() ); const XmlNode * resNode = xmlDoc.GetNode( "resource" ); std::string create = resNode->GetAttribute( "create" ); if( create == "true" ) { // 사전 생성 CreateDBDic( resNode ); // 사전 저장 XmlDocument xmlDoc; XmlNode * resNode = xmlDoc.AddNode( "resource" ); SaveToXML( resNode ); std::string path = "./resource/DBDic.xml"; xmlDoc.SaveFile( path.c_str() ); } else { // 사전 로드 XmlDocument xmlDoc; std::string path = "./resource/DBDic.xml"; xmlDoc.LoadFile( path.c_str() ); const XmlNode * resNode = xmlDoc.GetNode( "resource" ); LoadFromXML( resNode ); } }