如何在网站上显示 XML 的样式打印

How to display styled print out of XML on website

我正在使用一些 XML 我想在网站上展示它,但我更愿意展示一些风格化的版本。让我们在一些 boostrap table 或类似的东西中说,但不知何故我不知道如何。

示例XML:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
  <title>W3Schools Home Page</title>
  <link>http://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3schools.com/rss</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
</channel>

</rss>

假设我有这个 XML,我想将它设置为 table,其中:

     Title          |            Link              |              Desc
W3Schools Home Page | http://www.w3schools.com/rss | New RSS tutorial on W3Schools
XML Tutorial        | http://www.w3schools.com/xml | New XML tutorial on W3Schools

你能给我一些指示吗?或者有人可以为我编写示例代码以使其更清楚。

希望不要要求太多。谢谢大家!!

传统上这是通过 XSLT 完成的,它是浏览器的指令 sheet 自动将 xml 转换为 html。

签出:

https://greenbytes.de/tech/tc/xslt/

...一些很棒的书籍链接和其他信息。

有一些工作示例:

http://www.w3schools.com/xsl/xsl_examples.asp