http://www.perlmonks.org?node_id=941775


in reply to Validating XML

I use the following Perl 1-liner to help identify the offending part of a broken XML file:

perl -MXML::Parser -e "XML::Parser->new( ErrorContext => 3 )->parsefil +e(shift)" filename.xml

The diagnostic output from XML::Parser includes an ASCII arrow pointing to the bad bit. Of course if the line in question is over 1300 bytes long then that might be a little hard to read :-(