Is there any way to select only elements which pass a schema validation using LinqToXML?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Call the Validate method http://msdn.microsoft.com/en-us/library/bb354954.aspx, setting the
addSchemaInfoargument totrue, then select elements where the method http://msdn.microsoft.com/en-us/library/bb342577.aspx tells you the element has been successfully validated e.g.doc.Descendants().Where(el => el.GetSchemaInfo().Validity == System.Xml.Schema.XmlSchemaValidity.Valid).