Как восстановить завершающие слэши у одинарных тегов в этом скрипте: PHP: <?php $imp = new DOMImplementation; $dtd = $imp->createDocumentType("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); $doc = $imp->createDocument("", "", $dtd); $html = $doc->appendChild($doc->createElement("html")); $html_xmlns = $html->setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); $head = $html->appendChild($doc->createElement("head")); $cache = $head->appendChild($doc->createElement("meta")); $cache_equiv = $cache->setAttribute("http-equiv", "Content-Type"); $cache_content = $cache->setAttribute("content", "text/html; charset=utf-8"); $cache = $head->appendChild($doc->createElement("meta")); $cache_equiv = $cache->setAttribute("http-equiv", "Cache-Control"); $cache_content = $cache->setAttribute("content", "no-cache"); $icon = $head->appendChild($doc->createElement("link")); $icon_href = $icon->setAttribute("shortcut-icon", "favicon.ico"); $icon_type = $icon->setAttribute("type", "image/x-icon"); $title = $head->appendChild($doc->createElement("title")); $title_text = $title->appendChild($doc->createTextNode("This is the title")); $body = $html->appendChild($doc->createElement("body")); $header = $body->appendChild($doc->createElement("div")); $header_id = $header->setAttribute("id", "header"); $header_h1 = $header->appendChild($doc->createElement("h1")); $header_h1_text = $header_h1->appendChild($doc->createTextNode("This is the header")); $contenter = $body->appendChild($doc->createElement("div")); $contenter_id = $contenter->setAttribute("id", "contenter"); $contenter = $body->appendChild($doc->createElement("br")); $footer = $body->appendChild($doc->createElement("div")); $footer_id = $footer->setAttribute("id", "header"); $footer_anchor = $footer->appendChild($doc->createElement("a")); $footer_anchor_href = $footer_anchor->setAttribute("href", "http://www.example.com"); $footer_anchor_title = $footer_anchor->setAttribute("title", "example"); $footer_anchor_target = $footer_anchor->setAttribute("target", "_blank"); $footer_anchor_text = $footer_anchor->appendChild($doc->createTextNode("Powered by example | example © 2008-2009, [url=http://www.example.com]www.example.com[/url]")); $doc->normalizeDocument(); print $doc->saveHTML(); ?> Результат выполнения скрипта: HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Cache-Control" content="no-cache"> <link shortcut-icon="favicon.ico" type="image/x-icon"> <title>This is the title</title> </head> <body> <div id="header"><h1>This is the header</h1></div> <div id="contenter"></div> <br><div id="header"><a href="http://www.example.com" title="example" target="_blank">Powered by example | example © 2008-2009, [url=http://www.example.com]www.example.com[/url]</a></div> </body> </html> Как видите пропали завершающие слэши у одинарных тегов! Если использовать saveXML() вместо saveHTML(), получается белиберда - все теги в одну строку пишутся - очень не удобно просматривать получившийся код: HTML: <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Cache-Control" content="no-cache" /><link shortcut-icon="favicon.ico" type="image/x-icon" /><title>This is the title</title></head><body><div id="header"><h1>This is the header</h1></div><div id="contenter"></div><br /><div id="header"><a href="http://www.example.com" title="example" target="_blank">Powered by example | example © 2008-2009, [url=http://www.example.com]www.example.com[/url]</a></div></body></html> Есть выход из этой попы?
Все разобрался, помог Доктор Штопор в этой теме http://php.ru/forum/viewtopic.php?p=143889 Нужно поставить: formatOutput = true; PHP: $doc->formatOutput = true; Тогда при создании XML документа, на выходе будет отформатированный XHTML.
Парни чувствую что у меня проблема где-то рядом с вашей, но пока немогу разобраться есть xsl файл, в нём строка вида Код (Text): <xsl:value-of select='@vstavit' /> есть php файл, часть кода которого Код (Text): $m = $this->DOMDocument->getElementsByTagName("Document"); $r = $m->item(0); $sp="<!-- -->"; $r->setAttribute("vstavit",$sp); в получившемся html коде страницы вместо <---> получается < --- > каким образом реализовать вставку спецсимволов <> в исходный html код?