Bostonasian wrote:
I need to write a method that takes System.Xml.XmlDocument and Xsd Path
to validate XmlDocument.
How can I convert XmlDocument to XmlReader?
[.NET 1.X]
Efficient way is to use XmlNodeReader, but that won't help with
validation. For validation you need XmlTextReader, so usual way of doing
it (not really efficient, but working one) is
XmlTextReader r = new XmlTextReader(new StringReader(xmlDoc.OuterXml));
XmlvalidatingReader vr = new XmlValidatingReader(r);
....
[.NET 2.0]
In .NET 2.0 XmlDocument has Validate() method.
--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net http://blog.tkachenko.com