You are here: Specifying a DTD for a DOMDocument « PHP Programming Language « IT news, forums, messages
Specifying a DTD for a DOMDocument

Posted by bmichel on 10/23/07 09:22

Hey,

I'd like to specify the DTD file for a DOMDocument on creation; so I
can validate it.
The DTD file already exists (let's call it content.dtd)

$dom = new DOMDocument('1.0', 'utf-8');
// Do something here to link cotnent.dtd to the DOMDocument. How do I
do that?

// Form the xml document.
$dom->createElement('root_node');
....


I found through the php documentation that I can validate xml content
against a DTD if load the XML file (but not if I create it). Something
like that (assuming the xml content is in file content.xml which
specifies *<!DOCTYPE root_node SYSTEM "content.dtd">*):

$dom = new DOMDocument;
$dom->Load('content.xml');
if ($dom->validate()) {
// document is valid
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация