bonjour à tous,
j'ai créé un flux xml et j'aimerais valider ce flux par rapport à un fichier xsd.
Existe t-il un moyen de réaliser ceci ?
XmlValidator répond t-il à cettte problématique ?
merci à tous
bonjour à tous,
j'ai créé un flux xml et j'aimerais valider ce flux par rapport à un fichier xsd.
Existe t-il un moyen de réaliser ceci ?
XmlValidator répond t-il à cettte problématique ?
merci à tous
Tu peux utiliser un code qui ressemble à ça :
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 private bool validationSuccess; private List<string> errorsInXml; private XmlReaderSettings settings = new XmlReaderSettings(); private bool validateXML(string path) { validationSuccess = true; errorsInXml = new List<string>(); try { settings.Schemas.Add(null, "../../CheckXml.xsd"); settings.ValidationType = ValidationType.Schema; settings.ConformanceLevel = ConformanceLevel.Auto; settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); XmlReader URI_XMlreader = XmlReader.Create(path, settings); while (URI_XMlreader.Read()) { } } catch { return false; } return validationSuccess; } private void ValidationCallBack(object sender, ValidationEventArgs args) { validationSuccess = false; errorsInXml.Add(args.Message); XmlSchemaException ex = args.Exception; string message = string.Format(ex.Message + Environment.NewLine + "Ligne n° " + ex.LineNumber); MessageBox.Show(message); }
merci pour ta réponse je vais tester tout ceci (y)
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager