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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Data;
public struct profil
{
public string nom, prenom;
};
namespace IF
{
class Program
{
static void Main(string[] args)
{
int cmp=0;
profil[] _profil = new profil[4];
string nom;
string prenom;
/*for (int j = 0; j < 4; j++)
{
_profil[j].nom = "\0";
_profil[j].prenom = "\0";
}*/
XPathDocument doc = new XPathDocument("profil.xml");
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator iter = nav.Select("profils/profil");
while (iter.MoveNext())
{
_profil[cmp].nom = iter.Current.SelectSingleNode("Nom").Value;
_profil[cmp].prenom = iter.Current.SelectSingleNode("Prenom").Value;
try
{
nom = iter.Current.SelectSingleNode("Nom").Value;
prenom = iter.Current.SelectSingleNode("Prenom").Value;
}
catch (NullReferenceException e)
{
Console.WriteLine("{0} Caught Exception #1 ", e);
}
catch
{
Console.WriteLine("Caught Exception 2.");
}
finally
{
Console.WriteLine("Excecuting finally block.");
}
cmp += 1;
Console.WriteLine(" Nom : {0} Prenom : {1}", nom, prenom);
}
Console.Read();
}
}
} |
Partager