Re: [PHP-XML-DEV] Validating XML
[email protected] (Michael) Mon, 26 Apr 2004 21:50:10 -0400
| Newsgroups | php.general,php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
Hi Adam,
Thanks for the reply. I am guessing that the schemaValidate() method is
new and related to your work on revamping the DOM extension.
It appears that the docs for this extension have not yet caught up.
Besides trying to figure out the C code (i'm no C coder and that would
be a bit of a task although any tips would be appreciated), how would
you recommend that a Joe like me figure out what the extension can do in
its current incarnation?
Also, I'm wondering about DOM XML and simpleXML status. Both are
documented as being experimental. Are both in a state of flux right
now? Also, will they be in a stable state as PHP5 stable is released?
Thanks for your time.
Michael
Adam Maccabee Trachtenberg wrote:
> On Mon, 26 Apr 2004, Michael wrote:
>
>
>> I saw that the new simpleXML extension did have a method that
>>appeared to validate XML against a schema file, but this method now
>>appears to be removed from the current PHP 5 release candidate.
>>What other options are available to PHP?
>
>
> You can validate files in PHP 5 using the DOM extension:
>
> $file = 'foo.xml';
> $schema = 'foo.xsd';
> $foo = DOMDocument::load($file);
>
> if ($foo->schemaValidate($schema)) {
> print "$file is valid.\n";
> } else {
> print "$file is invalid.\n";
> }
>
> This does XML Schema validation, but there's also relaxNGValidate()
> for RelaxNG. If your document declares a DTD, then you can call
> validate() for a DTD validation.
>
> -adam
>