以下示例将完成这项工作。
假设您有以下文件:
测试.xml
<?xml version="1.0"?>
<product>
   <node>
       <region_id>
                <node>1</node>
       </region_id>
       <region_time>
                <node>27</node>
                <node>02</node>
                <node>2013</node>
       </region_time>
   </node>
</product>
test.xsl 更新
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:strip-space elements="*"/>
 <xsl:template match="*">
  <xsl:copy>
   <xsl:apply-templates select="*"/>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="node">
  <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="/">
    <xsl:apply-templates />
 </xsl:template>
 <!-- from dimitre\'s xsl.thanks -->
 <xsl:template match="node[position()>1]/text()">
   <xsl:text>,</xsl:text>
   <xsl:value-of select="."/>
 </xsl:template>
</xsl:stylesheet>
xslt.php
$sourcedoc = new DOMDocument();
$sourcedoc->load('test.xml');
$stylesheet = new DOMDocument();
$stylesheet->load('test.xsl');
// create a new XSLT processor and load the stylesheet
$xsltprocessor = new XSLTProcessor();
$xsltprocessor->importStylesheet($stylesheet);
// save the new xml file
file_put_contents('test-translated.xml', $xsltprocessor->transformToXML($sourcedoc));