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:
@@ -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>
|
||||
@@ -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)>
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user