Re: [xml] XML validation



Daniel Veillard wrote:
On Mon, Jan 15, 2007 at 05:52:19PM -0800, Rush Manbert wrote:
Yan Seiner wrote:
I have an embedded system that uses XML extensively. Many of the XML files are modified and generated by other software. I am looking for a simple XML well-formedness checker, something I can point at an XML file and tell the user that s/he has a problem with file xyz.xml around line YYY or maybe element XXX.

Does any such thing exist? I've found RXP, but it doesn't use libxml.... I really don't want to introduce more stuff into my (already bloated) embedded box...
The obvious answer is xmllint

  yes

(which needs a DTD).

  no :-) . Well formedness is tested just by running
    xmllint --noout file.xml

and only well-formedness errors will be printed there, and possibly some
warning (which can be suppressed with --nowarning).
Then validity can be checked against the DTD (--valid or --dtdvalid),
or XSD and Relax-NG (see xmllint help), but that doesn't seems to be the
question.

Daniel


My bad for not reading the docs on xmllint far enough. I missed the well-formedness check it does completely.....

Has anyone written it as a function, so I could call it from within PHP? What I would like to do is the following:

1.  PHP backend parses XML file using domxml_open_file
2.  parse fails
3. PHP then invokes xmllint on the failed xml file, and the PHP backend presents the user with a coherent message as to where the parse failed.

I could probably hack something together using the xmllint --htmlout option, but it would be neater if it was all packaged up... :-)

--Yan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]