Can't find unclosed element in XML

I use Notepad++ which has an excellent XML Tools plugin that lets you check XML Syntax and takes you to the line that is problematic. It also has useful utilities.

enter image description here


I just opened an XML file in VS 2010 (with ReSharper), broke the XML and what do you know? The error was highlighted immediately. If you have access to the same, it's that simple.


xmllint is a standard tool for this. From the Validation & DTDs page:

The simplest way is to use the xmllint program included with libxml. The --valid option turns-on validation of the files given as input. For example the following validates a copy of the first revision of the XML 1.0 specification:

xmllint --valid --noout test/valid/REC-xml-19980210.xml

the -- noout is used to disable output of the resulting tree.

The --dtdvalid dtd allows validation of the document(s) against a given DTD.

Libxml2 exports an API to handle DTDs and validation, check the associated description.

If your document isn't "pretty-printed" it can still be hard to find the offending node, so you might want to use xmllint to rewrite the file to be indented.

Tags:

Xml