<main sCol="1">
<section_0 name="Тестовая секция 1 (короткие ответы)" qCol="3" qAsk="3">
<question_0_0 type="shortanswer" name="Имя тестового вопроса 1">
<questiontext>
Текст тестового вопроса 1
</questiontext>
<answers aCol="1">
<answer_0_0_0 fr="1">Ответ 1</answer_0_0_0>
</answers>
</question_0_0>
<question_0_1 type="shortanswer" name="Имя тестового вопроса 2">
<questiontext>
Текст тестового вопроса 2
</questiontext>
<answers aCol="1">
<answer_0_1_0 fr="1">Ответ 2</answer_0_1_0>
</answers>
</question_0_1>
<question_0_2 type="shortanswer" name="Имя тестового вопроса 3">
<questiontext>
Текст тестового вопроса 3
</questiontext>
<answers aCol="1">
<answer_0_2_0 fr="1">Ответ 3</answer_0_2_0>
</answers>
</question_0_2>
</section_0>
</main>
XML, не получить значения в цикле
Код:
Код:
Test1->numOfSections = StrToInt(Doc->ChildNodes->Nodes[WideString("main")]->Attributes[WideString("sCol")]);
Test1->sections = new TSection*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")];
for (int i = 0; i < Test1->numOfSections; i++) {
Test1->sections = new TSection;
Test1->sections->id = i;
Test1->sections->name = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("name")];
Test1->sections->numOfQuestions = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("qCol")];
Test1->sections->numOfAskedQuestions = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("qAsk")];
Test1->sections->questions = new TQuestion*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")]->ChildNodes->Nodes[WideString("section_"+IntToStr(i))];
for (int j = 0; j < Test1->sections->numOfAskedQuestions; j++) {
Test1->sections->questions[j] = new TQuestion;
Test1->sections->questions[j]->id = j;
Test1->sections->questions[j]->type = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->Attributes[WideString("type")];
Test1->sections->questions[j]->name = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->Attributes[WideString("name")];
Test1->sections->questions[j]->text = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("questiontext")]->NodeValue;
Test1->sections->questions[j]->numOfAnswers = StrToInt(Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("answers")]->Attributes[WideString("aCol")]);
Test1->sections->questions[j]->answers = new TAnswer*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")]->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("answers")];
for (int k = 0; k < Test1->sections->questions[j]->numOfAnswers; k++) {
Test1->sections->questions[j]->answers[k] = new TAnswer;
Test1->sections->questions[j]->answers[k]->id = k;
Test1->sections->questions[j]->answers[k]->fr = StrToBool(Doc->ChildNodes->Nodes[WideString("answer_"+IntToStr(i)+"_"+IntToStr(j)+"_"+IntToStr(k))]->Attributes[WideString("fr")]);
Test1->sections->questions[j]->answers[k]->answer = Doc->ChildNodes->Nodes[WideString("answer_"+IntToStr(i)+"_"+IntToStr(j)+"_"+IntToStr(k))]->NodeValue;
}
}
}
Test1->sections = new TSection*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")];
for (int i = 0; i < Test1->numOfSections; i++) {
Test1->sections = new TSection;
Test1->sections->id = i;
Test1->sections->name = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("name")];
Test1->sections->numOfQuestions = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("qCol")];
Test1->sections->numOfAskedQuestions = Doc->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->Attributes[WideString("qAsk")];
Test1->sections->questions = new TQuestion*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")]->ChildNodes->Nodes[WideString("section_"+IntToStr(i))];
for (int j = 0; j < Test1->sections->numOfAskedQuestions; j++) {
Test1->sections->questions[j] = new TQuestion;
Test1->sections->questions[j]->id = j;
Test1->sections->questions[j]->type = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->Attributes[WideString("type")];
Test1->sections->questions[j]->name = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->Attributes[WideString("name")];
Test1->sections->questions[j]->text = Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("questiontext")]->NodeValue;
Test1->sections->questions[j]->numOfAnswers = StrToInt(Doc->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("answers")]->Attributes[WideString("aCol")]);
Test1->sections->questions[j]->answers = new TAnswer*;
Doc = DocIntf->ChildNodes->Nodes[WideString("test")]->ChildNodes->Nodes[WideString("quiz")]->ChildNodes->Nodes[WideString("main")]->ChildNodes->Nodes[WideString("section_"+IntToStr(i))]->ChildNodes->Nodes[WideString("question_"+IntToStr(i)+"_"+IntToStr(j))]->ChildNodes->Nodes[WideString("answers")];
for (int k = 0; k < Test1->sections->questions[j]->numOfAnswers; k++) {
Test1->sections->questions[j]->answers[k] = new TAnswer;
Test1->sections->questions[j]->answers[k]->id = k;
Test1->sections->questions[j]->answers[k]->fr = StrToBool(Doc->ChildNodes->Nodes[WideString("answer_"+IntToStr(i)+"_"+IntToStr(j)+"_"+IntToStr(k))]->Attributes[WideString("fr")]);
Test1->sections->questions[j]->answers[k]->answer = Doc->ChildNodes->Nodes[WideString("answer_"+IntToStr(i)+"_"+IntToStr(j)+"_"+IntToStr(k))]->NodeValue;
}
}
}
Еще один вопрос - как средствами C++ просто и эффективно зашифровать/дешифровать файл?
Цитата: anivaros
Еще один вопрос - как средствами C++ просто и эффективно зашифровать/дешифровать файл?
Использовать, например, DCPcrypt Cryptographic Component Library. Насколько я помню, она бесплатна.
Цитата:
Installation:
C++ Builder: Create a new design time package and add all the .pas
files from the DCPcrypt2.zip archive including all those
in the Ciphers and Hashes subdirectories. Then press the
install button.
You may need to add the directory containing DCPcrypt (and the Ciphers
and Hashes subdirectories) to your library search path (found under
Environment Options).
Once installed you will find two extra pages of components on your
component palette, namely DCPciphers and DCPhashes. You can now place
these components onto the form of your application to start using the
algorithms.
C++ Builder: Create a new design time package and add all the .pas
files from the DCPcrypt2.zip archive including all those
in the Ciphers and Hashes subdirectories. Then press the
install button.
You may need to add the directory containing DCPcrypt (and the Ciphers
and Hashes subdirectories) to your library search path (found under
Environment Options).
Once installed you will find two extra pages of components on your
component palette, namely DCPciphers and DCPhashes. You can now place
these components onto the form of your application to start using the
algorithms.
Что мне сделать надо, что бы я мог использовать библиотеку в C++ Builder 2009?