2013-10-21 21 views
1

我試圖解析這個XML換行和空格,而在表

<ssa_admin_tablereports> 
    <ssa_admin_tablereport_property name='ADM' value='&#10;Tables     :0&#10;Partitions    : 0&#10;Files     : 0&#10;Total size (Archive) : 0&#10;Total size (Update)  : 0&#10;Total size (Arc/Upd) : 0%/0%&#10;Total size    : 0&#10;Total rows    : 0&#10;Flat file size (Archive): 0&#10;Flat file size (Update) : 0&#10;Flat file size (Arc/Upd): 0%/0%&#10;Flat file size   : 0&#10;Compression ratio  : not defined&#10;'> 
    </ssa_admin_tablereport_property> 
    <ssa_admin_tablereport_property name='TORRENT' value='&#10;Tables     : 53&#10;Partitions    : 97&#10;Files     : 194&#10;Total size (Archive) : 1980098&#10;Total size (Update)  : 586499&#10;Total size (Arc/Upd) : 77%/23%&#10;Total size    : 2566597&#10;Total rows    : 213404&#10;Flat file size (Archive): 9189418&#10;Flat file size (Update) : 6830067&#10;Flat file size (Arc/Upd): 57%/43%&#10;Flat file size   : 16019485&#10;Compression ratio  : 84.0%&#10;'> 
    </ssa_admin_tablereport_property> 
</ssa_admin_tablereports> 

用於此的XSLT是解析使用XSLT多行XML屬性值崩潰:

<pre><dd> 
        <table border="1"> 
         <tbody> 
         <tr> 
          <th>Table Name</th> 
          <th>Table Report</th> 
         </tr> 
         <xsl:for-each select="ssa_admin_tablereports/ssa_admin_tablereport_property"> 
          <tr> 
           <td valign="top"><xsl:value-of select="@name"/></td> 
           <td valign="top"><xsl:value-of select="@value"/></td> 
          </tr> 
         </xsl:for-each>    
         </tbody> 
        </table> 
</dd></pre> 

但是當我打開帶有瀏覽器的XML文件,值屬性中出現的換行符和空格被替換爲單個空格。那麼我怎樣才能以與XML相同的方式獲得它?

回答

2

HTML不允許table一個pre裏面,但反過來想應該是罰款 - 嘗試把pretd

<xsl:for-each select="ssa_admin_tablereports/ssa_admin_tablereport_property"> 
    <tr> 
     <td valign="top"><xsl:value-of select="@name"/></td> 
     <td valign="top"><pre><xsl:value-of select="@value"/></pre></td> 
    </tr> 
</xsl:for-each> 
+0

呀,現在它的工作。謝謝伊恩羅伯茨 – Prateek