I'm creating XML parser using C#. I need to display all exceptions on the windows form that I am using. However, I can only get one exception at a time.

for example, I'm parsing: test.xml

<xml>
<head>
<title>Book</title>
<head>
<xml>

If you notice there are 2 unclosed tags for head and xml tags. This is part of the c# code:

        catch (XmlException f)
            {
                MessageBox.Show(f.Message);                   
            }

If I run the program, it will only throw an exception to tell that head tag is unclosed.
However, if I just corrected the unclosed tag for head(i.e. /head), then the exception will now only throw regarding xml tag. Is there a way to scan the whole xml file without throwing errors first, at the end of the scan, throw both exceptions to user at the same time?

An exception, of any type, is always thrown on the first encountered error.

Here's my take on it:
If you want to throw one single exception for all occuring errors, then you need to read the entire file into a string variable with a TextReader, and create a parser that scans the string for all possible reasons an error could occur.