JavaScript & XML: validate an XML document

I think we all know how to use XML documents. For example RSS feeds are basically XML files, as well as sitemaps. Those files may be very important when managing a web site, but those examples are just a small part of the common use of XML documents. Just to make things clear, another example: when you export a Blogger blog, the file you get is an XML file.
When I've written the article on how to create an RSS feed, I discovered a very useful JavaScript snippet that helps us to validate an XML file.
Unfortunately I don't remember where I got it, but, even if I surely rearranged it, if you know the original source, please let me know so that I can give due credit to the author.
Ok, said that, let's see how to do it.
The code
First of all, let's create a form like the following:

 
 
In the input element, we need to insert a valid path to an XML file (it can be local or remote, it doesn't matter).
Then we have a button which will trigger the Validate() function:
I decided to leave the comments in the code itself, so it will be easier to understand what it is actually doing.
Now, you may wonder what res is.  Well, it's quite easy: we use a HTML element to show the results of the validation process. So somewhere on the page we need to insert the following:
That's the place where the results will appear.

Let me know what you think.