本文整理汇总了C++中XmlDocument::GetNode方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlDocument::GetNode方法的具体用法?C++ XmlDocument::GetNode怎么用?C++ XmlDocument::GetNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument::GetNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
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 );
}
}
示例2: LoadAnswerRule
void AnswerGenerator::LoadAnswerRule( AnswerRuleList & answerRuleList )
{
// 질문 템플릿 xml 로드
XmlDocument xmlDoc;
std::string path = "./resource/AnswerRule.xml";
xmlDoc.LoadFile( path.c_str() );
const XmlNode *resNode = xmlDoc.GetNode( "resource");
//
int nodeCount = resNode->GetNodeCount( "ans" );
for( int num = 0; num < nodeCount; num++ )
{
// Question template node들을 돌며,
const XmlNode * sqlNode = resNode->GetNode( "ans", num );
std::string templateNum = sqlNode->GetAttribute( "tempNo" );
std::string subNum = sqlNode->GetAttribute( "no" );
//
AnswerRule rule;
rule._tempNo = atoi( templateNum.c_str() );
rule._subNo = atoi( subNum.c_str() );
const XmlNode * needListNode = sqlNode->GetNode( "need_slot_list" );
// 만약 num번째 Question template에서,
int slotCount = needListNode->GetNodeCount( "slot" );
for( int num2 = 0; num2 < slotCount; num2++ )
{
// slot의 개수만큼 돌며
// 속성들을 읽어오고,
const XmlNode * slotNode = needListNode->GetNode( "slot", num2 );
std::string slotType = slotNode->GetAttribute( "type" );
std::string tagName = slotNode->GetAttribute( "value" );
std::string addText = slotNode->GetAttribute( "add" );
//
AnswerNeedSlot slot;
slot._slotType = slotType;
slot._tagName = tagName;
slot._addText = addText;
rule._needSlotList.push_back( slot );
}
const XmlNode * tableNode = sqlNode->GetNode( "table" );
std::string expression1 = tableNode->GetAttribute( "exp" );
rule._reference._expression = expression1;
int expCnt = tableNode->GetNodeCount( "exp" );
for( int num2 = 0; num2 < expCnt; num2++ )
{
//
const XmlNode * expNode = tableNode->GetNode( "exp", num2 );
std::string expType = expNode->GetAttribute( "type" );
DataElement element = GetElement( expType );
rule._reference._elementList.push_back( element );
}
const XmlNode * answerNode = sqlNode->GetNode( "answer" );
std::string expression2 = answerNode->GetAttribute( "exp" );
rule._answer._expression = expression2;
int expCount = answerNode->GetNodeCount( "exp" );
for( int num2 = 0; num2 < expCount; num2++ )
{
//
const XmlNode * expNode = answerNode->GetNode( "exp", num2 );
std::string expType = expNode->GetAttribute( "type" );
DataElement element = GetElement( expType );
rule._answer._elementList.push_back( element );
}
answerRuleList.push_back( rule );
}
}