简体   繁体   中英

how can I do DTD and schema validation on a xml file in PHP?

i have this xml file called data_out.xml, and i want to do DTD and SCHEMA checks on the xml file using SIMPLEXML and php. thank you very much :))

Simplexml won't do it but DomDocument can do it. Also the xml should have some link to the DTD file.

<?php
$dom = new DOMDocument;
$dom->Load('book.xml');
if ($dom->validate()) {
    echo "This document is valid!\n";
}
?>

you can take a look at this question for more references

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM