Example #1
0
bool DBDictionary::SaveToXML( XmlNode * resNode )
{
	int size = _dic.size();
	for( int num = 0; num < size; num++ )
	{
		TableDataForDic tableDataList = _dic[num];
		std::string tableName = tableDataList._tableName;

		XmlNode * tableNode = resNode->AddNode( "table" );
		tableNode->SetAttribute( "name", tableName.c_str() );

		int colSize = tableDataList._dataList.size();
		for( int cnt = 0; cnt < colSize; cnt++ )
		{
			const ColDataForDic & colDataList = tableDataList._dataList[ cnt ];
			std::string colName = colDataList._colName;

			XmlNode * colNode = tableNode->AddNode( "col" );
			colNode->SetAttribute( "name", colName.c_str() );

			int dataSize = colDataList._dataList.size();
			for( int k = 0; k < dataSize; k++ )
			{
				const std::string & data = colDataList._dataList[ k ];

				XmlNode * dataNode = colNode->AddNode( "data" );
				dataNode->SetAttribute( "text", data.c_str() );
			}
		}
	}
	return true;
}
Example #2
0
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() );
}