Bonjour,
Je cherche à remplir un dictionnaire via des fichiers Xml, J'ai le code suivant :
Chaque objets d'un fichier Xml possède le même nom de base situé sous :
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 private Dictionary<string, string[]> GetUserValues(IDataSource dataSource, string type) { IDictionary<string, byte[]> userValuesByte = dataSource.LoadValues(type); Dictionary<string, string[]> userValues = new Dictionary<string, string[]>(); if (userValuesByte == null) { return null; } foreach (string table in userValuesByte.Keys) { if (userValuesByte[table].Length != 0) { using (MemoryStream ms = new MemoryStream(userValuesByte[table])) { using (StreamReader reader = new StreamReader(ms)) { //string newText = SimpleTextEditor.Show(reader.ReadToEnd()); XmlTextReader xmlReader = new XmlTextReader(reader); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlReader); XmlNodeList nodes = xmlDocument.SelectNodes(".//Object"); foreach (XmlNode node in nodes) { XmlNodeList child = node.ChildNodes; string nomTable = child.Item(3).InnerText; string nomChamp = child.Item(4).InnerText; } } } } } return userValues; }
Chaque objet d'un fichier Xml possède un nom de champ différent situé sous :
Code : Sélectionner tout - Visualiser dans une fenêtre à part child.Item(3).InnerText
Je souhaite donc avoir dans mon dictionnaire "userValues" quelque chose du type :
Code : Sélectionner tout - Visualiser dans une fenêtre à part child.Item(4).InnerText
Les tables seraient donc les clés et les champs les valeurs
Table 1 Champ 1 Table 1 Champ 2 Table 1 Champ 3 Table 2 Champ 1
N'hésitez pas à me dire si je n'ai pas été assez précis
Merci
Partager