title: Check for XML errors using JavaScript
body: <p><b>Question:</b> How do I syntax-check my XML in modern browsers (anything but IE)?</p>
  
  <p>I've seen <a href="http://www.w3schools.com/xml/xml_validator.asp">a page on W3Schools</a> which includes an XML syntax-checker. I don't know how it works, but I'd like to know how I may achieve the same behavior.</p>
  
  <p>I've already performed many searches on the matter (with no success), and I've tried using the DOM Parser to check if my XML is "well-formed" (also with no success).</p>
  
  <pre>
  var xml = 'Caleb';
  var parser = new DOMParser();
  var doc = parser.parseFromString(xml, 'text/xml');
  </pre>
  
  <p>I expect the parser to tell me I have an XML syntax error (i.e. an unclosed <i>name</i> tag). However, it always returns an XML DOM object, as if there were no errors at all.</p>
  
  <p>To summarize, I would like to know how I can automatically check the syntax of an XML document using JavaScript.</p>
  
  <p><i>P.S. Is there any way I can validate an XML document against a DTD (using JS, and not IE)?</i></p>