getaway
getaway

Reputation: 8990

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 :))

Upvotes: 3

Views: 1716

Answers (1)

RageZ
RageZ

Reputation: 27323

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

Upvotes: 2

Related Questions