Click to See Complete Forum and Search --> : [RESOLVED] DOMDocument xhtml help


sad1sm0
09-13-2008, 11:50 AM
I am creating an extension for DomDocument that allows for specifically custom xhtml output. I used cdata to display the Doctype but I can't validate against it because it's just the declaration. However, the doctype property of the DOMDocument is by default a read-only property. My first question is how do you define a DTD for a document using DOMDocument class. Also, why doesn't php automatically close tags with no content. what i mean is i do this:

$xhtml->documentElement->appendChild($xhtml->createElement('input');

and expect to see source like this:

<input />

instead what i get is :
<input>

how do i tell php that this tag needs to be closed. I thought that this would be automatic but apparently I'm wrong. I tried saving xml and html and the result was the same.

Any help would be appreciated so thanks in advance

sad1sm0
10-16-2008, 01:09 PM
Just an update for anyone who may come across this thread.

DOMDocuments can't by themselves be given a DOCTYPE. To declare the doctype, it is necessary to use DOMImplementation class and create the DOMDocument thru there after you have created your doctype. When you create the DOMDocument you use the doctype as an argument.