看看
PHP’s DOM,特别是
DOMDocument::schemaValidate和
DOMDocument::validate.
DOMDocument :: validate的例子相当简单:
<?PHP $dom = new DOMDocument; $dom->Load('book.xml'); if ($dom->validate()) { echo "This document is valid!\n"; } ?>