Checking multiple XML files for errors with Shell script and PHP

A joomla site I work on is throwing an XML error, with, of course, no information on what file is throwing the error.There are 1260 XML files on the server, so I’m not about to check them all by hand.

The first task is to locate and list all the XML files in the site in a text file:

I then tried to write a script to process each line of that file (based on ) and use xmllint to check the file, and again output the results to a file. Unfortunately, xmllint doesn’t seem to like appending with >> and while you can specify an output file, I don’t want 1260 results files either! So I wrote a php script to do the job instead.

Note that in all these snippets, you will need to replace the paths and domains with yours, of course. So, this worked nicely. Except that most of the XML files don’t have a DTD, and those that do seem to completely ignore it, so everything comes out as invalid. Just… great. I love working with Joomla.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *