Monday, November 2, 2009

Debug XML Documents

Author:Thales Jacobi
Debug XML Document with PHP

How to find out where is the problem with your XML document?

1. Fastest solution - 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.

2. Slowest solution:
- 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.

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

Web debugging tool

What is this debugger?
This PHP debugger is the beginning of the XML mini-portal, a Bubaweb.com project, and is growing from just an idea into a real-life XML resources.

How can I use this debugger?
You can copy and past an Iframe, from the link above, into your page or use a web service provided by Bubaweb.com at XML Debugger API Web Service.

Source code
You can find the PHP class and examples of use at the PHPClasses.org, package 5675
XML curiosity, Well-Formed XML Documents.

A textual object is a well-formed XML document if:

- Taken as a whole, it matches the production labeled document.
- It meets all the well-formedness constraints given in this specification.
- Each of the parsed entities which is referenced directly or indirectly within the document is well-formed.

Matching the document production implies that:

- It contains one or more elements.
- There is exactly one element, called the root, or document element, no part of which appears in the content of any other element. For all other elements, if the start-tag is in the content of another element, the end-tag is in the content of the same element. More simply stated, the elements, delimited by start- and end-tags, nest properly within each other.

XML Introduction
Extensible Markup Language (XML) is a simple, very flexible text format designed to help large-scale electronic publishing. XML is also playing an increasingly important role in the exchange of a wide variety of data on the Web and elsewhere.XML Markup vocabularyWe envision applications of Extensible Markup Language (XML) where a single XML document may contain elements and attributes that are defined for and used by multiple software modules. It is the namespaces specification the idea behind this is: if such a markup vocabulary exists which is well-understood and for which there is useful software available, it is better to re-use this markup rather than re-invent it.

No comments:

Post a Comment