Bonsoir ,je débute en C# et je souhaiterais lire un fichier XML , j'ai procedé ainsi :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
 
public struct strprofil
{
    public string nom,prenom;
};
 
namespace ConsoleApplication2
{
 
    public class Program
    {
        static void Main(string[] args)
        {
            int i=0;
            strprofil[] profil = new profil[2];
            XmlTextReader filexml = XmlTextReader("profil.xml");
            filexml.WhitespaceHandling = WhitespaceHandling.None;
 
            while (filexml.LocalName == "YZ")
            {
                profil[i].nom = filexml.ReadString();
                filexml.Read();
                profil[i].prenom = filexml.ReadString();
                filexml.Read();
                i += 1;   
            }
            Console.WriteLine(" {0}", profil[0].nom);
            Console.ReadLine();
        }
    }
}
Le fichier profil.xml est :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
<?xml version="1.0"?>
<profil>
	<profil>
		<nom>YZ</nom>
		<prenom>Z</prenom>
	</profil>
	<profil>
		<nom>X</nom>
		<prenom>XY</prenom>
	</profil>
</profil>
Le résultat est que j'obtiens rien en sortie ( je pensais obtenir YZ )
Où est le problème ?
Merci