]> granicus.if.org Git - php/commitdiff
add a DTD example
authorShane Caraveo <shane@php.net>
Thu, 9 Oct 2003 05:46:03 +0000 (05:46 +0000)
committerShane Caraveo <shane@php.net>
Thu, 9 Oct 2003 05:46:03 +0000 (05:46 +0000)
ext/dom/examples/note-invalid.xml [new file with mode: 0644]
ext/dom/examples/note.dtd [new file with mode: 0644]
ext/dom/examples/note.php [new file with mode: 0644]

diff --git a/ext/dom/examples/note-invalid.xml b/ext/dom/examples/note-invalid.xml
new file mode 100644 (file)
index 0000000..58d4e65
--- /dev/null
@@ -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> 
diff --git a/ext/dom/examples/note.dtd b/ext/dom/examples/note.dtd
new file mode 100644 (file)
index 0000000..4016eb5
--- /dev/null
@@ -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)>
\ No newline at end of file
diff --git a/ext/dom/examples/note.php b/ext/dom/examples/note.php
new file mode 100644 (file)
index 0000000..a8695f3
--- /dev/null
@@ -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";
+}
+
+?>