You are here: RE: [PHP] How to build a XML DTD on "the fly"? « PHP « IT news, forums, messages
RE: [PHP] How to build a XML DTD on "the fly"?

Posted by "Jared Williams" on 11/19/05 00:29

> The code below lacks the part where the folling DTD attribute is
> created: <!ATTLIST document id ID #IMPLIED>
>
> How can I create the above DTD attribute in the code below?
>
> <?php
> // Creates an instance of the DOMImplementation class
> $oDomImp = new DOMImplementation;
>
> // Creates a DOMDocumentType instance
> $oDomDtd = $oDomImp->createDocumentType('document', null, null);
>
> // Creates a DOMDocument instance
> $oDom = $oDomImp->createDocument("", "", $oDomDtd);
>
> // Set other properties
> $oDom->encoding = 'iso-8859-1';
> $oDom->standalone = true;
>
> // Create an empty element
> $oElement = $oDom->createElement('document', 'test');
> $oElement->setAttribute('id', '123'); // Append the element
> $oDom->appendChild($oElement);
>
> // Retrieve and print the document
> echo $oDom->saveXML() . "\n";
>
> echo "TagName: " . $oDom->getElementById('123')->tagName;
> ?>
>
> Now the code produces the following result:
>
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
> <!DOCTYPE document> <document id="123">test</document>
>
> TagName:
>

There is no real standard for creating DTDs on the fly, and therefore libxml/DOM doesn't have any methods afaik.

The one method DOMElement::setIDAttribute() should work I think, but whilst PHP has the method, doesn’t seem todo anything. :/

Jared

 

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

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