Rechercher une valeur dans un ficher xml

Résolu
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 - 8 juil. 2010 à 11:12
Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 - 7 oct. 2018 à 08:08
bonjour,

j'ai suivie un tutoriel sur YouTube pour ajouter modifier supprimer les données dans un ficher XML mais je ne sait pas comment chercher une valeur dans se ficher comme si en étais sur sql server mais malheureusement il y a pas une raquette a insérer


la Base Xml

?xml version= "1.0" standalone="yes"?>


2
N59
SonyEricsson
12




1
N95
Nokia
14








source C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Data.Sql;
namespace xml_connector
{
public partial class Form1 : Form
{
DataSet dsproduit = new DataSet("produits");
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
dsproduit.ReadXml("c:\\base2.xml");
txtid.DataBindings.Add("Text", dsproduit, "Produit.ID");
txtRefrence.DataBindings.Add("Text", dsproduit, "Produit.Refrence");
txtNom.DataBindings.Add("Text", dsproduit, "Produit.Nom");
txtqt.DataBindings.Add("Text", dsproduit, "Produit.Qut");
}

private void button1_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "Produit"].EndCurrentEdit();
this.BindingContext[dsproduit, "Produit"].AddNew();
dsproduit.WriteXml("c:\\base2.xml");
}

private void button2_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "Produit"].RemoveAt(this.BindingContext[dsproduit, "Produit"].Position);
dsproduit.WriteXml("c:\\base2.xml");
}

private void button4_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "produit"].CancelCurrentEdit();
}

private void button6_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "produit"].Position = 0;
}

private void button8_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "produit"].Position += 1;
}

private void button5_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "produit"].Position -= 1;
}

private void button7_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "produit"].Position =
this.BindingContext[dsproduit, "produit"].Count - 1;
}

private void button3_Click(object sender, EventArgs e)
{
this.BindingContext[dsproduit, "Produit"].EndCurrentEdit();
dsproduit.WriteXml("c:\\base2.xml");
}
}
}



j'ai mis la source pour que vous pouvez m'aider est pour ce qui en chercher a connecter C# a
XML un code simple avec sa base

remarque la base doit être placé dans c:\base2.xml

source complet sur 2shared 35kb
http://www.2shared.com/file/iF6SolTZ/c_to_xml.html

merci d'avance

6 réponses

nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 37
8 juil. 2010 à 21:13
Salut,

Il faut utiliser le DOM de c#

Exemple de methode selectsiglenode ou selectnodes
et les autres fonctions

sinon il y a linq2XML si tu es en 2008 ou 2010

bon dev
3
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 1
8 juil. 2010 à 21:48
merci je vais faire de mon mieux
0
nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 37
8 juil. 2010 à 21:52
0
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 1
10 juil. 2010 à 21:12
bonsoir,

merci nhervagault c'est exactement ce que je chercher
tu est le meilleur
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Bidou Messages postés 5487 Date d'inscription dimanche 4 août 2002 Statut Membre Dernière intervention 20 juin 2013 61
12 juil. 2010 à 01:04
0
sureshdasari Messages postés 1 Date d'inscription dimanche 7 octobre 2018 Statut Membre Dernière intervention 7 octobre 2018
Modifié le 7 oct. 2018 à 07:38
Thank you so much it helped me to solve my problem in c#. If you want to learn more about c# check following tutorial.

https://www.tutlane.com/tutorial/csharp
0
Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 656
7 oct. 2018 à 08:08
Bonjour, ce forum est francophone, donc on essaye d'y parler français, mais surtout, on propose des tutoriels en français.
0
Rejoignez-nous