Thank you for your answer. But i still don't understand XML files :( I look some guides or web sites , but i don't understand.
OK - try starting here : https://en.wikipedia.org/wiki/Well-formed_document[^]
<question>
<number>1</number>
<options>
<option>
<number>1</number>
<optionText>option 1 text</optionText>
<option>
<option>
<optionNumber>n</optionNumber>
<optionText>option n text</optionText>
<option>
</options>
<responses>
<response>1</response>
</responses>
</question>
Is this XML code for only one question?
What is the Options and Option blocks?
Can you organize your XML code to my code(only one question) please? It helps me a lot...
Yes. That is the layout for one question.
The <options> block contains all the text of possible answers to the question.
I missed <text> element to hold the the question text. See the example below.
A concrete example.
<question>
<number>1</number>
<text>Aberdeen is a city in which country?</text>
<options>
<option>
<number>1</number>
<optionText>Scotland</optionText>
</option>
<option>
<number>2</number>
<optionText>United States of America</optionText>
</option>
<option>
<number>3</number>
<optionText>Nepal</optionText>
</option>
</options>
<responses>
<response>1</response>
<response>2</response>
</responses>
</question>
On the other hand, i don't understand some parts of your codes, which are;
while (unanswered.Count > 0) {
int qNo = (new Random()).Next(unanswered.Count+1));
question = unanswered(qNo);
unanswered.RemoveAt(qNo);
answered.Add(question);
getUserResponse(question);
}
In this code,is "getUserResponse" is a separate function,if it is what is inside this function?
It's just pseudo-code to show where you would write code to display the question and get the user's answer(s).
List<question< unanswered = new List<question<();
List<question< answered = new List<question<>();
XmlNodeList nodelist = root.SelectNodes(myQuestionPath);
foreach (XmlNode n in nodelist) {
unanswered.Add(new question(n));
}
In this code, you wrote "// Assume document is loaded and we have the root node.// Get the full list of question nodes." , in this section of code i wrote this code ,is this code right?
Probably. I didn't look closely at it. :)
XmlTextReader xmlrd = new XmlTextReader(@"C:\\Users\Onur\Desktop\xml deneme.xml");
XmlDocument doc = new XmlDocument();
doc.Load(xmlrd);
XmlNode root = doc.SelectSingleNode("question");
XmlNodeList list = root.SelectNodes("options");
In this code ,first you wrote Number but you never used it, what is it?
Second, you created 3 lists which are "Options","Responses" and " Answers" , but i can't figure how to implement this lists using my XML file.
class question {
public question(XmlNode q) {}
public Number {get; set;}
public List<option> Options {get; set;}
public List<response> Responses {get; set;}
public List<answer> Answers {get; set;}
}
Again this is just pseudo-code to suggest one possible way that you might hold an XMLNode in your XML file in C# class. Number would be loaded from a question XMLNode as would the question text and the options and responses. Answers will hold the user's responses.
Thank you again...