Bonjour,
Je dois transformer un fichier XML en fichier CSV pour ce faire je me suis dit que j'allais désérialiser le fichier XML pour ensuite écrire dans un fichier CSV.
Pour des raisons de confidentialité je ne peux vous fournir le fichier XML cependant il a la structure suivante :
- une balise Service contient plusieurs balises folder1
- une balise folder1 contient plusieurs balises folder2
- une balise folder2 contient plusieurs balises folder3
- une balise folder3 contient plusieurs balises file
Le fichier faisant plus de 1700 lignes et ne m'appartenant pas merci de ne pas me demander de modifier complètement la structure.
Et voici ma classe permettant de désérialisé ce fichier :
Le problème est le suivant : le programme programme plante lors de l'initialisation de
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 SerializationObject { [XmlRoot("file")] public class _File { [XmlAttribute("id")] public string id { get; set; } [XmlAttribute("name")] public string name { get; set; } [XmlAttribute("path")] public string path { get; set; } [XmlAttribute("type")] public string type { get; set; } [XmlAttribute("lang")] public string lang { get; set; } [XmlAttribute("xmlns")] public string xmlns { get; set; } } [XmlRoot("folder3")] public class _Folder3 { [XmlAttribute("id")] public string id { get; set; } [XmlAttribute("name")] public string name { get; set; } [XmlAttribute("path")] public string path { get; set; } [XmlAttribute("type")] public string type { get; set; } [XmlArrayItem("file")] public List<_File> folder3 { get; set; } } [XmlRoot("folder2")] public class _Folder2 { [XmlAttribute("id")] public string id { get; set; } [XmlAttribute("name")] public string name { get; set; } [XmlAttribute("path")] public string path { get; set; } [XmlAttribute("type")] public string type { get; set; } [XmlArrayItem("folder3")] public List<_Folder3> folder2 { get; set; } } [XmlRoot("folder1")] public class _Folder1 { [XmlAttribute("id")] public string id { get; set; } [XmlAttribute("name")] public string name { get; set; } [XmlAttribute("path")] public string path { get; set; } [XmlAttribute("type")] public string type { get; set; } [XmlArrayItem("folder2")] public List<_Folder2> folder1 { get; set; } } [XmlRoot("Service")] public class _Service { [XmlAttribute("xmlns")] public string xmlns { get; set; } [XmlArrayItem("folder1")] public List<_Folder1> Service { get; set; } } }Pouvez-vous m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part List<_Folder1> Service
Merci d'avance
Cordialement
Winflow
Partager