Bonjour à tous... j'Ai un petit problème avec le xml serializer.... .
j'Essaie d'enregistrer des données sous format xml avec le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 privatevoid btnEnregistrer_Click(object sender, EventArgs e) { XmlSerializer serializer = newXmlSerializer(typeof(XmlInventaire),"Inventaire"); XmlInventaire xInvent = newXmlInventaire(); xInvent.Description = unProduit.Description; xInvent.Numero = unProduit.Numero; xInvent.Quantite = Convert.ToDouble(txtQuantite.Text); serializer.Serialize(fichierInvent, xInvent); lblInformations.Text = "Num‚ro : \nDescription : \nEmplacement : \nQuantit‚ : \nPrix Coutant :"; txtQuantite.Text = ""; searchBox1.filterClear(); btnEnregistrer.Enabled = false; }
et celà produit le code suivant.....
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 <?xmlversion="1.0"encoding="utf-8"?> <XmlInventairexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Numero>PL221.........</Numero> <Description>ABLOY CADENAS (LARG=33MM)</Description> <Quantite>1</Quantite> </XmlInventaire><?xmlversion="1.0"encoding="utf-8"?> <XmlInventairexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Numero>010...........</Numero> <Description>ABLOY CLEF</Description> <Quantite>177</Quantite> </XmlInventaire><?xmlversion="1.0"encoding="utf-8"?> <XmlInventairexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Numero>Y-5...........</Numero> <Description>MEDECO CLEF 5 Y3</Description> <Quantite>201</Quantite> </XmlInventaire><?xmlversion="1.0"encoding="utf-8"?> <XmlInventairexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Numero>006-03010.....</Numero> <Description>MUL-T-LOCK KIK WEISER 5 PIN LT S/A</Description> <Quantite>3</Quantite> </XmlInventaire><?xmlversion="1.0"encoding="utf-8"?> <XmlInventairexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns="Inventaire"> <Numero>PL221.........</Numero> <Description>ABLOY CADENAS (LARG=33MM)</Description> <Quantite>1</Quantite> </XmlInventaire>
ce qui me donne l'erreur suivante....
quelqu'un à un idée sur comment regler ce problème...
The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. Only one top level element is allowed in an XML document. Error processing resource 'file:///C:/Documents and Settings/Ian/...
<XmlInventaire xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlnssd="http://www.w3.org/2001/XMLSchema">-^
Il faut que je puisse ouvrir et fermer mon logiciel et pouvoir ajouter des données à la fin du document XML peu importe le moment...
Merci
FadeOut
Partager