简体   繁体   中英

linq to xml validation against a DTD file in c#

I have a xml file that has

I am using linq to xml for parsing this xml. I have searched for validation of xml in linq to xml and most of the examples I get are validation against a xsd file.

Can please anyone tell me how to use linq to xml for validation against a DTD file.

Thanks.

Much obliged

From the documentation for XDocumentType :

LINQ to XML will not validate a document against a DTD, but you can use a validating XmlReader to perform DTD validation if necessary.

So it sounds like you'll need to validate the Xml using an XmlReader before trying to read it using Linq to XML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM