XML VALIDATION
-
Thursday, December 27, 2012 11:24 AM
HI,
i have a code like:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFileName);I have a doubt if i have bad xmlfile, will it get validated while loading? If yes why we have
public void Validate(ValidationEventHandler validationEventHandler);
- Moved by John SaundersMVP Friday, December 28, 2012 5:28 PM xml q (From:ASMX Web Services and XML Serialization)
All Replies
-
Friday, December 28, 2012 5:38 PM
If you want to validate you will need to use a validating XmlReader you pass to the Load method, that way you can validate while loading the document, or you need to use the Validate method (which also helps validating after some manipulation has been done in-memory on the DOM tree). See http://msdn.microsoft.com/en-us/library/w5aahf2a.aspx for details and examples on those two options.MVP Data Platform Development My blog
- Proposed As Answer by Martin Honnen Friday, December 28, 2012 5:38 PM

