nyoto
Messages postés47Date d'inscriptionmercredi 3 novembre 2004StatutMembreDernière intervention 2 mai 2006
-
8 déc. 2005 à 13:45
nyoto
Messages postés47Date d'inscriptionmercredi 3 novembre 2004StatutMembreDernière intervention 2 mai 2006
-
9 déc. 2005 à 17:38
Lut gens,
J'ai une super question sur laquelle je ne trouve pas de réponse sur le web.
Je cherche à faire une requête sur un doc XML afin de récupérer des enregistrements.
Mon XML est de forme :
<Zone>
<CP>01 000 Bourg-en-Bresse</CP>
<REF>0107</REF>
<VOISINS>0105,E</VOISINS>
</Zone>
<Zone>
<CP>01 100 Oyonnax</CP>
<REF>0101</REF>
<VOISINS>0105,SW;3904,N</VOISINS>
</Zone>
Je voudrais en fait récupérer REF et Voisins en fonction de CP.
Est ce possible avec des requêtes Xpath ?
Quelle est la syntaxe correcte ?
nyoto
Messages postés47Date d'inscriptionmercredi 3 novembre 2004StatutMembreDernière intervention 2 mai 2006 8 déc. 2005 à 16:49
Alors mon code doit merder ...
J'arrive bien à utiliser une variable pour mon CP ...
le string est bon mais après je suis pas sûr de ce que j'ai fait ... c'est de là que doit venir la merde !!!
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
//on lit le fichier XML, on lève une erreur en cas de pépin
String fichier = "zones.xml";
try
{
using (FileStream fin =
new FileStream (fichier, FileMode.Open, FileAccess.Read))
{
doc.Load(fin);
}
}
catch(XmlException e)
{
System.Windows.Forms.MessageBox.Show(
this,
"Le fichier XML <" + fichier + "> est *mal formé*. Il ne peut être lu.\nL'application va se terminer.\n\n>>Message original :\n" + e.Message,
"Erreur",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error
);
Application.Exit();
}
catch(FileNotFoundException e)
{
System.Windows.Forms.MessageBox.Show(
this,
"Le fichier XML <" + fichier + "> ne peut être trouvé.\nL'application va se terminer.\n\n>>Message original :\n" + e.Message,
"Erreur",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error
);
Application.Exit();
}
catch(UnauthorizedAccessException e)
{
System.Windows.Forms.MessageBox.Show(
this,
"Le fichier XML <" + fichier + "> ne peut être lu faute de droits suffisant. Contactez votre admin.\nL'application va se terminer.\n\n>>Message original :\n" + e.Message,
"Erreur",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error
);
Application.Exit();
}
catch(IOException e)
{
System.Windows.Forms.MessageBox.Show(
this,
"Le fichier XML <" + fichier + "> a causé une erreur d'Entrée/Sortie.\nL'application va se terminer.\n\n>>Message original :\n" + e.Message,
"Erreur",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error
);
Application.Exit();
}
}
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected
override
void Dispose(
bool disposing )
{
if( disposing )
{
if (components !=
null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private
void InitializeComponent()
{
this.dsZones =
new System.Data.DataSet();
this.label1 =
new System.Windows.Forms.Label();
this.comboBox1 =
new System.Windows.Forms.ComboBox();
this.label2 =
new System.Windows.Forms.Label();
this.label3 =
new System.Windows.Forms.Label();
this.textBox1 =
new System.Windows.Forms.TextBox();
this.dsZones.Locale =
new System.Globalization.CultureInfo("fr-FR");
//
// label1
//
this.label1.Font =
new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location =
new System.Drawing.Point(176, 16);
this.label1.Name = "label1";
this.label1.Size =
new System.Drawing.Size(128, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Choix de la ville :";
this.label1.Click +=
new System.EventHandler(
this.label1_Click);
//
// comboBox1
//
this.comboBox1.Items.AddRange(
new
object[] {
"01 000 - Bourg en Bresse",
"01 100 - Oyonnax",
"02 405 - Château Thierry",
"06 000 - Nice",
"06 200 - Nice",
"08 000 - Charleville Mézières",
"10 300 - Sainte-Savine",
"13 001 - Marseille",
"14 000 - Caen",
"17 000 - La Rochelle",
"21 000 - Dijon",
"25 000 - Besançon",
"26 000 - Valence",
"28 300 - Leves",
"29 000 - Quimper",
"29 200 - Brest",
"30 100 - Ales",
"30 900 - Nîmes",
"31 000 - Toulouse",
"33 000 - Bordeaux",
"34 000 - Montpellier",
"34 420 - Villeneuve les Béziers",
"35 135 - Chantepie",
"37 550 - Saint-Avertin",
"38 100 - Grenoble",
"38 200 - Vienne",
"42 100 - Saint Etienne",
"44 400 - Reze",
"44 600 - Saint Nazaire",
"45 000 - Orléans",
"49 000 - Angers",
"50 100 - Cherbourg",
"51 100 - Reims",
"54 000 - Nancy",
"57 070 - Metz",
"58 000 - Nevers",
"59 650 - Villeneuve d\'Ascq",
"60 000 - Beauvais",
"60 200 - Compiègne",
"62 300 - Lens",
"63 100 - Clermont Ferrand",
"64 200 - Biarritz",
"64 230 - Lescar",
"66 000 - Perpignan",
"67 000 - Strasbourg",
"68 000 - Colmar",
"68 100 - Mulhouse",
"69 009 - Lyon",
"69 400 - Villefranche sur Saône",
"71 000 - Mâcon",
"71 100 - Châlon sur Saône",
"72 000 - Le Mans",
"73 000 - Chambéry",
"73 200 - Albertville",
"74 160 - Archamps",
"76 000 - Rouen",
"76 370 - Neuville les Dieppes",
"79 000 - Niort",
"80 000 - Amiens",
"81 100 - Castres",
"82 005 - Montauban",
"83 160 - La Valette",
"84 000 - Avignon",
"85 200 - Fontenay le Comte",
"86 000 - Poitiers",
"87 000 - Limoges"});
this.comboBox1.Location =
new System.Drawing.Point(312, 16);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size =
new System.Drawing.Size(224, 21);
this.comboBox1.TabIndex = 1;
this.comboBox1.Text = "Choix de la ville";
this.comboBox1.SelectedIndexChanged +=
new System.EventHandler(
this.comboBox1_SelectedIndexChanged);
//
// label2
//
this.label2.Location =
new System.Drawing.Point(232, 56);
this.label2.Name = "label2";
this.label2.Size =
new System.Drawing.Size(88, 24);
this.label2.TabIndex = 3;
this.label2.Text = "Prévisions pour ";
//
// label3
//
this.label3.Location =
new System.Drawing.Point(320, 56);
this.label3.Name = "label3";
this.label3.Size =
new System.Drawing.Size(200, 24);
this.label3.TabIndex = 4;
//
// textBox1
//
this.textBox1.Location =
new System.Drawing.Point(216, 152);
this.textBox1.Name = "textBox1";
this.textBox1.Size =
new System.Drawing.Size(288, 20);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize =
new System.Drawing.Size(5, 13);
this.ClientSize =
new System.Drawing.Size(792, 570);
this.Controls.Add(
this.textBox1);
this.Controls.Add(
this.label3);
this.Controls.Add(
this.label2);
this.Controls.Add(
this.comboBox1);
this.Controls.Add(
this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load +=
new System.EventHandler(
this.Form1_Load);