Salut !
Je débute tout juste avec Linq et XML et j'ai un petit souci :
Voici classe sur laquelle je travaille :
Dans ma form, est déclaré ceci :
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
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
64
65
66
67
68
69
70
71
72 public class Extrait { private String _Artiste; private String _Titre; private double _PointA; private double _PointT; private double _PointAT; private List<String> _JoueurA; private List<String> _JoueurT; private List<String> _JoueurAT; public String Artiste { get { return _Artiste; } set { _Artiste = value; } } public String Titre { get { return _Titre; } set { _Titre = value; } } public Double PointA { get { return _PointA; } set { _PointA = value; } } public Double PointT { get { return _PointT; } set { _PointT = value; } } public Double PointAT { get { return _PointAT; } set { _PointAT = value; } } public List<String> JoueurA { get { return _JoueurA; } set { _JoueurA = value; } } public List<String> JoueurT { get { return _JoueurT; } set { _JoueurT = value; } } public List<String> JoueurAT { get { return _JoueurAT; } set { _JoueurAT = value; } } public Extrait(String Artiste, String Titre, Double PointA, Double PointT, Double PointAT, List<String> JoueurA, List<String> JoueurT, List<String> JoueurAT) { _Artiste = Artiste; _Titre = Titre; _PointA = PointA; _PointT = PointT; _PointAT = PointAT; _JoueurA = JoueurA; _JoueurT = JoueurT; _JoueurAT = JoueurAT; } }
Voici le début de ma méthode pour sérialiser :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 public partial class Form1 : Form { private Extrait[] extraits; ...
Je souhaite à présent accéder au contenu des list JoueurAT, JoueurA et JoueurT; comme vous le voyez ci-dessus, j'ai déjà accédé à l'indice 0 de l'élément. Maintenant, je voudrais la liste complète des indices supérieurs à zéro, s'ils existent.
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 private void button3_Click(object sender, EventArgs e) { XDocument xDoc = new XDocument( new XElement("blind", new XElement("nombre_titres", nbextrait), new XElement("numero", textBox1.Text), new XElement("theme", textBox4.Text), new XElement ("mdp",textBox2.Text), new XElement("lien",textBox5.Text), new XElement ("playlist", from ex in extraits select new XElement("extrait", new XElement("artiste",ex.Artiste), new XElement("titre",ex.Titre), new XElement("blindeur_tout",ex.JoueurAT[0]), new XElement("blindeur_artiste", ex.JoueurA[0]), new XElement("blindeur_titre", ex.JoueurT[0]) ) ) ) ); xDoc.Save(_folder + "Blind.xml"); }
Mais voilà, je ne vois pas du tout comment faire ...
Merci de votre aide !![]()
Partager