PHP 5.4.31 Released

DomXsltStylesheet->result_dump_mem

(PHP 4 >= 4.1.0)

DomXsltStylesheet->result_dump_mem Dumps the result from a XSLT-Transformation back into a string

Description

string DomXsltStylesheet::result_dump_mem ( DomDocument $xmldoc )

Since DomXsltStylesheet->process always returns a well-formed XML DomDocument, no matter what output method was declared in

<xsl:output>
and similar attributes/elements, it's of not much use, if you want to output HTML 4 or text data.

This function on the contrary honors

<xsl:output method="html|text">
and other output control directives. See the example for instruction on how to use it.

Examples

Example #1 Outputting the result of a XSLT transformation

<?php
$filename 
"stylesheet.xsl";
$xmldoc domxml_open_file("data.xml");
$xsldoc domxml_xslt_stylesheet_file($filename);
$result =  $xsldoc->process($xmldoc);
echo 
$xsldoc->result_dump_mem($result);     
?>

add a note add a note

User Contributed Notes 1 note

up
0
lsoethout at hotmail dot com
8 years ago
The function result_dump_mem has a problem with the meta content type tag. It outputs it like this:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

which is not correct X(HT)ML, because it closes with '>' instead of with '/>'.

A way to get the output correct is to use instead of result_dump_mem :

    $domHtmlText = $domTranObj->html_dump_mem();

or, as a second alternative:

    $domHtmlText = $domTranObj->dump_mem(true);
To Top