note 45765 added to ref.dom
| From: | jw at jwscripts dot com | Date: | Fri, 17 Sep 2004 16:21:00 +0000 |
| Subject: | note 45765 added to ref.dom | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76887@lists.php.net to get a copy of this message | ||
The following shows how to add a DTD to an XML document:
<?php
// Create an instance of the DomImplementation class
$impl = new DomImplementation;
// Create an instance of the DomDocumentType class by
// calling the DomImplementation::createDocumentType() method
// (arguments: doctype_name, doctype_public, doctype_system)
$dtd = $impl->createDocumentType("graph", "", "graph.dtd");
// Create an instance of the DomDocument class by
// calling the DomImplementation::createDocument() method
// (arguments: NS_URL, NS_PREFIX, DomDocumentType_instance)
$dom = $impl->createDocument("", "", $dtd);
// Set other properties
$dom->encoding = "UTF-8";
$dom->standalone = "no";
// Create an empty element
$element = $dom->createElement("graph");
// Append the element
$dom->appendChild($element);
// Retrieve and print the document
print $dom->saveXML());
/*
Result:
=========
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE graph SYSTEM "graph.dtd">
<graph/>
*/
?>
----
Manual Page -- http://www.php.net/manual/en/ref.dom.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45765
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45765&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45765&report=yes
Search -- http://master.php.net/manage/user-notes.php