你要的XSL文件﹕<?xml version="1.0" encoding="UTF-8"?> 
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict">
<body style="font-family:Arial,helvetica,sans-serif;font-size:12pt; background-color:#EEEEEE"><xsl:for-each select="document">
<span><xsl:value-of select="left"/></span>
<span><xsl:value-of  select="with"/></span>
</xsl:for-each><xsl:for-each select="document/element/button">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold;color:white">
  <xsl:value-of select="name" /> 
  </span>
  
  <xsl:value-of select="text" /> 
  </div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
  <xsl:value-of select="top" /> 
<span style="font-style:italic">
  ( 
  <xsl:value-of select="left" /> 
  calories per serving) 
  </span>
  </div>
  </xsl:for-each>
  </body>
  </html>你的XML加入你的XSL﹕
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="6.xsl"?>
<document>
    <width>300</width>
    <height>300</height>
    <title>表单</title>
    <element>
        <button>
            <left>90</left>
            <top>66</top>
            <width>119</width>
            <height>37</height>
            <name>htmlbutton1</name>
            <text>测试</text>
        </button>
    </element>
    <width>300</width>
    <height>300</height>
    <title>表单</title>
    <element>
        <button>
            <left>90</left>
            <top>66</top>
            <width>119</width>
            <height>37</height>
            <name>htmlbutton1</name>
            <text>测67试</text>
        </button>
    </element>
</document>

解决方案 »

  1.   

    加外在html中格式化xml
    <html>
    <body>
    <xml id="cdcat" src="ted.xml"></xml>
    <table border="1" datasrc="#cdcat">
    <tr>
    <td><span datafld="left"></span></td>
    <td><span datafld="top"></span></td>
    <td><span datafld="width"></span></td>
    </tr>
    </table>
    </body>
    </html> td.xml文件內容﹕
    <?xml version="1.0" encoding="UTF-8"?>
    <document>
           <button>           
              <left>90</left>
                <top>66</top>
                <width>119</width>
                <height>37</height>
                <name>htmlbutton1</name>
                <text>测试</text>
           </button>
       </document>
    ---------------------------------
    但是如果你的XML是你的那樣即里面有兩層子節點的我測試不成功﹗