开发者

Determine if XML file conforms to a specific schema

开发者 https://www.devze.com 2023-03-03 17:01 出处:网络
I have an System.IO.Stream object that may or may 开发者_JAVA技巧not be XML. What is the quickest/easiest way to determine if

I have an System.IO.Stream object that may or may 开发者_JAVA技巧not be XML.

What is the quickest/easiest way to determine if 1) Is this file XML and 2) if it is, then is it an instance of a particular schema?

In the end I really just trying to write a method that can return true or false if a particular Stream is an instance of a schema.

Thanks for the help!


I suggest you try to load is an XDocument, and then use XDocument.Validate. Return false if either the parsing or validation fails. There's some sample code on MSDN which does something pretty similar, and which would be a good starting point.

0

精彩评论

暂无评论...
验证码 换一张
取 消