Hi,
I've been developing a small xml parser for a specific file with this data structure :
<questionnaire type="Echo">
<quest etat="0" ord="0">
<intro>
<t>bla bla bla</t>
</intro>
<rep1>
<t>word</t>
<ev id="Q0R1"/>
</rep1>
<rep2>
<t>word</t>
<ev id="Q0R2"/>
</rep2>
</quest>
</questionnaire>
The <quest></quest>
tag is repeated 70 times in fact.
Here is the parser I developed in C# and which takes the parameter "xmlString" containing the XML to parse :
XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlString));
while(reader.ReadToFollowing("quest"))
{
Console.WriteLine("=================================");
Console.WriteLine("ID : " + reader.GetAttribute("ord").ToString());
reader.ReadToFollowing("intro");
reader.ReadToFollowing("t");
Console.WriteLine("TEXTE : " + reader.ReadString());
reader.ReadToFollowing("rep1");
reader.ReadToFollowing("t");
Console.WriteLine("REPONSE1 : " + reader.ReadString());
reader.ReadToFollowing("ev");
Console.WriteLine("CLE1 : " + reader.GetAttribute("id").ToString());
reader.ReadToFollowing("rep2");
reader.ReadToFollowing("t");
Console.WriteLine("REPONSE2 : " + reader.ReadString());
reader.ReadToFollowing("ev");
Console.WriteLine("CLE2 : " + reader.GetAttribute("id").ToString());
Console.WriteLine("ETAT : False");
}
Everything is ok through the 69 first < quest >, but when reaching the 70th, it the fields TEXTE and REPONSE1 are empty and it goes through a NullReferenceException at the line :
Console.WriteLine("CLE1 : " + reader.GetAttribute("id").ToString());
Can anybody tell me what's wrong ?? Thanks in advance.