Re: [PHP-XML-DEV] better way?
[email protected] (Kevin Waterson)
| Newsgroups | php.xml.dev |
|---|---|
| Organization | Oceania |
| Message-ID | <[email protected]> |
This one time, at band camp, "Rob Richards" <[email protected]> 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