How can I do DTD and schema validation in an XML file in PHP?

I have this xml file called data_out.xml and I want to do DTD and SCHEMA checks in an XML file using SIMPLEXML and php. many thanks:))

+3
source share
1 answer

Simplexml will not do this, but DomDocument can do it. Also, 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 look at question sitelinks

+2
source

Source: https://habr.com/ru/post/1780581/


All Articles