1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00

add a DTD example

This commit is contained in:
Shane Caraveo
2003-10-09 05:46:03 +00:00
parent 639216a4aa
commit d0cf1ec40d
3 changed files with 34 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>PHP User Group</to>
<from>Shane</from>
<heading>Reminder</heading>
<body>Don't forget the meeting tonight!</body>
<footer>Or I'll clobber you!</footer>
</note>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" ?>
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
+19
View File
@@ -0,0 +1,19 @@
<?php
$dom = new domDocument;
$dom->load('note.xml');
if (!$dom->validate('note.dtd')) {
print "Document note.dtd is not valid\n";
} else {
print "Document note.dtd is valid\n";
}
$dom = new domDocument;
$dom->load('note-invalid.xml');
if (!$dom->validate('note.dtd')) {
print "Document note-invalid.xml is not valid\n";
} else {
print "Document note-invalid.xml is valid\n";
}
?>