«^»
6.2. Getting the XML from somewhere else

Accessing a file of XML assumes that some other process has already created it (and keeps it up to date). It may be more useful for this XML to be generated by some other means. If we want to do this, we have to call the xslt_process function in a different way. Just to demonstrate how this is done, here is a PHP script that has some XML stored in a string variable:

<%
   $xml =
        "<?xml version=\"1.0\"?>"
      . "<consumables>"
      . "   <product>"
      . "      <category>cassette tape</category>"
      . "      <item>DC6150 cartridge</item>"
      . "      <price>9.50</price>"
      . "   </product>"
      . "</consumables>";
   $arguments = array("/_xml" => $xml);
   $xsltproc = xslt_create();
   $html = xslt_process($xsltproc, "arg:/_xml", "consumables.xsl", NULL, $arguments); 
   if (!$html) {
      die("XSLT processing error:" . xslt_error($xsltproc));
   }
   xslt_free($xsltproc);
   echo $html;
%> 

http://webster.dur.ac.uk/barry.cornelius/myphp/xslt/embeddedxml.php.