I am running xhtml-strict report on a bunch of pages and each time I find a page on a specific page I save it. I need to really look over all the page but what happens is that sometimes the XmlReader is failling but I cannot go on and check the rest of the file to report the errors.

XmlReader reader = XmlReader.Create(new System.IO.StringReader(xml), settings);

            try {

                bool hasData = !reader.EOF;
                while (hasData) {

                    try {
                        hasData = reader.Read();
                    } catch (Exception ex) {
                        Errors.Add(ex.Message);
                        reader.ReadEndElement();
                        //reader.Skip();
                    } finally {
                        hasData = !reader.EOF;
                    }
                }

            } catch (Exception ex) {
                Errors.Add("Exception while validating content: " + ex.Message);
            } finally {
                if (reader != null) reader.Close();
            }
        }

This is what I have at the moment but it causing infinite loop, it never passing on to the next. Any kind of move or skip seems to be working.

Thanks for your help!

I can also add to this explanation that the only errors I found it's failling on are Invalid Token and Entity Block error.

Here are the settings definition

XmlReaderSettings settings = new XmlReaderSettings();
            settings.ProhibitDtd = false;
            settings.ValidationType = ValidationType.DTD;
            settings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
This article has been dead for over six months. Start a new discussion instead.