Re: better way?
| From: | Kevin Waterson | Date: | Thu, 17 Jul 2003 22:17:05 +0000 |
| Subject: | Re: better way? | ||
| References: | 1 2 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-158@lists.php.net to get a copy of this message | ||
This one time, at band camp, "Rob Richards" <rrichards@ctindustries.net> wrote:
> The docs are based on the CVS version of dom.
Here is a your xml_xslt.txt file with corrections made for
new naming convention. this works with CVS dom.
Kevin
<?php
// create new xsltprocessor
$proc = new xsltprocessor();
// load domDocument from string
$dom2 = domDocument::loadxml('<?xml version="1.0"
encoding="UTF-8"?><root>hello world</root>');
// load domDocument from string
$dom = domDocument::loadxml('<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="root"/>
<p/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>');
// import stylesheet from domDocument
$proc->importStylesheet($dom);
// following are 3 ways to output the transformation
// write transformation output to a file (returns # bytes written)
print "Wrote: ".$proc->transformToURI($dom2,
'mystylesheet.txt')."\n\n";
// transformation output to a string (returns string)
print $proc->transformToXML($dom2)."\n\n";
// create domDocument from transformation (returns domDocument)
$result = $proc->transformToDoc($dom2);
// output domDocument xml to string
print $result->savexml();
?>
--
______
(_____ \
_____) ) ____ ____ ____ ____
| ____/ / _ ) / _ | / ___) / _ )
| | ( (/ / ( ( | |( (___ ( (/ /
|_| \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia