|
Posted by ZeldorBlat on 06/07/07 13:27
On Jun 6, 7:23 pm, Marijn <marijn.huizendv...@gmail.com> wrote:
> Hey everybody,
>
> The following has been posted before (2 years ago) but no response was
> added. Therefor again, the following code for creating xhtml file:
>
> <?php
>
> error_reporting(6143);
>
> $xmlns = "http://www.w3.org/1999/xhtml";
> $lang = "en";
>
> $xhtml_1_strict = new DomImplementation();
>
> $dtd_xhtml_1_strict = $xhtml_1_strict->createDocumentType("html", "-//
> W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/
> xhtml1-strict.dtd");
>
> $xhtml_1_strict_document = $xhtml_1_strict->createDocument("", "",
> $dtd_xhtml_1_strict);
> $xhtml_1_strict_document->encoding = "UTF-8";
> $xhtml_1_strict_document->standalone = "no";
>
> $html = $xhtml_1_strict_document->createElementNS($xmlns, "html");
> $html->setAttribute("xml:lang", $lang);
>
> $head = $xhtml_1_strict_document->createElement("head");
> $html->appendChild($head);
>
> $title = $xhtml_1_strict_document->createElement("title", "Testing the
> DOM in PHP5");
> $head->appendChild($title);
>
> $base = $xhtml_1_strict_document->createElement("base");
> $base->setAttribute("href", "http://test.beatter.com");
> $head->appendChild($base);
>
> $meta = $xhtml_1_strict_document->createElement("meta");
> $meta->setAttribute("http-equiv", "Content-Type");
> $meta->setAttribute("content", "application/xhtml+xml;UTF-8");
> $head->appendChild($meta);
>
> $body = $xhtml_1_strict_document->createElement("body");
> $html->appendChild($body);
>
> $xhtml_1_strict_document->appendChild($html);
>
> header("Content-type: application/xhtml+xml;UTF-8");
> echo($xhtml_1_strict_document->saveXML());
>
> ?>
>
> the expected output would be:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
> <head>
> <title>Testing the DOM in PHP5</title><base href="http://
> test.beatter.com" />
> <meta http-equiv="Content-Type" content="application/xhtml
> +xml;UTF-8" />
> </head>
> <body>
> </body>
> </html>
>
> but the output is:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=UTF-8" />
> <title>Testing the DOM in PHP5</title><base href="http://
> test.beatter.com" />
> </head>
> <body>
> </body>
> </html>
>
> Why does php add this node by itself? Why can't I override that
> behavior? Why does php change the order of outputing the elements (I'm
> appending, not pre-pending to the head element)?
>
> Thanks,
>
> Marijn
I've run into this problem, too. Unfortunately I've been unable to
find /any/ documentation on how/where/why this happens. It also seems
to depend on which version of the underlying XML libraries PHP is
using. I, too, would love to hear from anyone that has some insight
into this "feature."
Navigation:
[Reply to this message]
|