First of all to design the xml file as you want.
<levels>
<level>
<name>Level 1 (xml)</name>
<tutorial>Try comes close to all four objects. (xml)</tutorial>
<object name="Cube"> Hi, I'm a cube! (xml) </object>
<object name="Cylinder"> Hi, I'm a Cylinder! (xml) </object>
<object name="Capsule"> Hi, I'm a Capsule! (xml) </object>
<object name="Sphere"> Hi, I'm a Sphere! (xml)</object>
<finaltext>Very Good! (xml)</finaltext>
</level>
<level>
<name>Level 2 (xml)</name>
<tutorial>Try comes close to all four objects, again. (xml)</tutorial>
<object name="Cube"> Hi, I'm a cube in the level 2! (xml)</object>
<object name="Cylinder"> Hi, I'm a Cylinder in the level 2! (xml)</object>
<object name="Capsule"> Hi, I'm a Capsule in the level 2! (xml)</object>
<object name="Sphere"> Hi, I'm a Sphere in the level 2! (xml)</object>
<finaltext>Congratulations! (xml)</finaltext>
</level>
</levels>
Any node “level” can represents a question for your game.
Try to study this method: http://unitynoobs.blogspot.com/2011/02/xml-loading-data-from-xml-file.html
public void GetLevel()
{
XmlDocument xmlDoc = new XmlDocument(); // xmlDoc is the new xml document.
xmlDoc.LoadXml(GameAsset.text); // load the file.
XmlNodeList levelsList = xmlDoc.GetElementsByTagName("level"); // array of the level nodes.
foreach (XmlNode levelInfo in levelsList)
{
XmlNodeList levelcontent = levelInfo.ChildNodes;
obj = new Dictionary<string,string>(); // Create a object(Dictionary) to colect the both nodes inside the level node and then put into levels[] array.
foreach (XmlNode levelsItens in levelcontent) // levels itens nodes.
{
if(levelsItens.Name == "name")
{
obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
}
if(levelsItens.Name == "tutorial")
{
obj.Add("tutorial",levelsItens.InnerText); // put this in the dictionary.
}
if(levelsItens.Name == "object")
{
switch(levelsItens.Attributes["name"].Value)
{
case "Cube": obj.Add("Cube",levelsItens.InnerText);break; // put this in the dictionary.
case "Cylinder":obj.Add("Cylinder",levelsItens.InnerText); break; // put this in the dictionary.
case "Capsule":obj.Add("Capsule",levelsItens.InnerText); break; // put this in the dictionary.
case "Sphere": obj.Add("Sphere",levelsItens.InnerText);break; // put this in the dictionary.
}
}
if(levelsItens.Name == "finaltext")
{
obj.Add("finaltext",levelsItens.InnerText); // put this in the dictionary.
}
}
levels.Add(obj); // add whole obj dictionary in the levels[].
}
}
And to get the values:
string lvlName = "";
levels[actualLevel-1].TryGetValue("name",out lvlName);
string tutorial = "";
levels[actualLevel-1].TryGetValue("tutorial",out tutorial);
levels[actualLevel-1].TryGetValue("Cube",out Cube_Character);
levels[actualLevel-1].TryGetValue("Cylinder",out Cylinder_Character);
levels[actualLevel-1].TryGetValue("Capsule",out Capsule_Character);
levels[actualLevel-1].TryGetValue("Sphere",out Sphere_Character);
string finaltext = "";
levels[actualLevel-1].TryGetValue("finaltext",out finaltext);
Note: actualLevel is just a int value, you can increment it and pass with your answers.