XML Debugging


Monday, 7 September 2009
Structural problems (like missing quotes, unclosed tags, etc) can be a pain for development because PHP doesn't tell you where the error is, it just breaks the code. This technique can help you with that, although not perfect, it was designed to give the confidence to publish your web service (or your XML doc) without killing yours and other people's systems.

PHP Debugging Tool

Online Demo

Download PHP Class

This class proudly gave me the PHP Programming Innovation award winner in September 2009 from PHPClasses.org.

Debugging Techniques

Fastest solution

  1. Isolate the problem:
    • Delete the first half of the XML.
    • If the error disappeared, place it back on and delete just the first half of this half.
    • Continue deleting and placing back chunks of the XML until you get the only line that is causing the problem.
    • Now you can research on the single problem you have found.

Slowest solution

  1. More accurately:
    • If you can't find the problem using the previous approach, it is very likely that you have more than one bugs in the XML document to fix.
    • Execute the '1. Fastest solution' (the previous bullet point) on just the half of the XML document. Try to debug only a chunk of it at a time until all problems are fixed.

My solution

  1. Use the online tool XML debugger:
    • I've just developed to help on this process and is very simple to use.