summaryrefslogtreecommitdiff
path: root/ext/dom
diff options
context:
space:
mode:
authorShane Caraveo <shane@php.net>2003-10-09 05:46:03 +0000
committerShane Caraveo <shane@php.net>2003-10-09 05:46:03 +0000
commitd0cf1ec40d7ae39ad1d8a362146dffdeac2240fa (patch)
tree0ad0172e49326c8183a3f9efa70710a34c0534a8 /ext/dom
parent639216a4aa2800b91116ea9a06b0a9ae41c7ac80 (diff)
downloadphp-git-d0cf1ec40d7ae39ad1d8a362146dffdeac2240fa.tar.gz
add a DTD example
Diffstat (limited to 'ext/dom')
-rw-r--r--ext/dom/examples/note-invalid.xml9
-rw-r--r--ext/dom/examples/note.dtd6
-rw-r--r--ext/dom/examples/note.php19
3 files changed, 34 insertions, 0 deletions
diff --git a/ext/dom/examples/note-invalid.xml b/ext/dom/examples/note-invalid.xml
new file mode 100644
index 0000000000..58d4e65044
--- /dev/null
+++ b/ext/dom/examples/note-invalid.xml
@@ -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
index 0000000000..4016eb5811
--- /dev/null
+++ b/ext/dom/examples/note.dtd
@@ -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
index 0000000000..a8695f3664
--- /dev/null
+++ b/ext/dom/examples/note.php
@@ -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";
+}
+
+?>