Generate XHTML (HTML compatible) Code using DOMDocument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

After talking with Michael about how to generate XHTML code using the DOM I came up with this little function that I'm thinking of using to generate XHTML code that's HTML compatible:

function saveXHTML($dom) {
    $html = $dom->saveXML(null,LIBXML_NOEMPTYTAG);
    $html = str_replace('
','',$html);
    $html = preg_replace('/<\?xml[^>]*>\n/','',$html,1);
    $html = preg_replace('/<\!\[CDATA\[(.*)\]\]><\/script>/s','//<![CDATA[\1//]]></script>',$html);
    $html = preg_replace('/><\/(meta|link|base|basefont|param|img|br|hr|area|input)>/',' />',$html);
    return $html;
}

What do you think?


__
Raymond Irving

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux