How to validate an XML document?

前端 未结 2 2012
没有蜡笔的小新
没有蜡笔的小新 2020-12-16 23:43

My C#/.NET application reads XML files that are manually edited by the users. The allowed elements and tags are described in the application\'s documentation. I\'m using LIN

相关标签:
2条回答
  • 2020-12-17 00:13

    You can validate xml files against XSD.

    • First you have to create Xml Schema Definition file. See example
    • use XML Schema Definition Tool to create XSD from XMLfile
    • Use this code to validate input XML using corresponding XSD

    Hope this will help...

    EDIT

    This article explains all possible ways to validate xml, using C#
    How To Validate an XML Document by Using DTD, XDR, or XSD in Visual C# .NET

    IMO best option is to use XSD.

    0 讨论(0)
  • 2020-12-17 00:19

    Validating Input Xml Data Files

    0 讨论(0)
提交回复
热议问题