xslt php create xml from string

original

New Member
I've used the following piece of code to transform XML to another XML file. But I'm trying to use xslt to create a new XML file from a set of strings.\[code\] $xsl = simplexml_load_file('template.xsl'); $xslt = new XSLTProcessor; $xslt->setParameter('','foo',$foo); $xslt->setParameter('','bar',$bar); $xslt->setParameter('','test',$test); $xslt->importStyleSheet($xsl); $data = http://stackoverflow.com/questions/14083689/$xslt->transformToXML($xml);\[/code\]So what I'm doing is passing parameters to template.xsl which creates nodes and the resulting output is passed to $data, which PHP then write to a file. But the example code that I have expects a XML file to be read first and saved to a variable, $xml. But I'm not reading in a XML file because I'm generating strings for the data and this generates 'PHP Warning: XSLTProcessor::transformToXml() expects parameter 1 to be object, null given'. I realise that I can use PHP to write the XML - http://www.developerfusion.com/code/3944/how-to-create-xml-files/ - But I would like to know how to do this with xslt.Thanks
 
Back
Top