开发者

Determine if XML file conforms to a specific schema

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜