如何将XML转换为可读的东西?

sen*_*hin 5 xml

我有一个巨大的xml文件,我想将其转换为可读格式.

这是我的xml文件的样子:

<entries>
<entry title="earth" id="9424127" date="2006-04-19T08:22:16.140">
<![CDATA[earth is the place where we live.]]>
</entry>
</entries>
Run Code Online (Sandbox Code Playgroud)

所以我有超过5000个这样的条目,我想把它们放在网上,这样我就可以轻松阅读它们.我怎么能转换它?

这是我想要的输出:

地球

地球是我们生活的地方.(2006-04-19T08:22:16.140)

Dan*_*ley 6

您可以使用XSLT样式表来创建一个简单的html表.

例如,这个样式表:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/entries">
    <html>
      <body>
        <table border="1">
          <xsl:apply-templates/>
        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="entry">
    <tr>
      <td><xsl:value-of select="@title"/></td>
      <td>
        <xsl:apply-templates/>
      </td>
      <td>(<xsl:value-of select="@date"/>)</td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

会创造:

<html>
  <body>
    <table border="1">
      <tr>
        <td>earth</td>
        <td> earth is the place where we live. </td>
        <td>(2006-04-19T08:22:16.140)</td>
      </tr>
    </table>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)