首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正在尝试以html格式显示XML

正在尝试以html格式显示XML
EN

Stack Overflow用户
提问于 2018-05-12 00:03:19
回答 1查看 39关注 0票数 0

在这个基本的XML类中,我完全理解不了,我正在努力弄清楚自己在做什么。我一直在尝试弄清楚如何使用XSLT显示XML文档,使其看起来像这样:

https://i.stack.imgur.com/mdedM.png

我的XML:

代码语言:javascript
复制
   <systemMetadata>
          <title>Koha</title>
          <creator>by Katipo Communications</creator>
           <subject>library community, research, information services,public 
           libraries, bibliographic management, distributed library systems, metadata, 
           resource discovery, conferences,lectures, workshops</subject>
          <description>Koha was one of the the first open-source Integrated Library Systems 
         It is used and maintained by the worldwide library community.</description>
          <date>2000</date>
           <type>ILS</type>
           <rights>Open-source</rights>
          <identifier>http://www.koha.org/</identifier>
      </systemMetadata>
   <aboutRecord>
          <recordCreator>Created by Matthew Weidemann</recordCreator>
          <creationDate>on 2018-05-03</creationDate> 
      </aboutRecord>

非常感谢你的任何想法。

EN

回答 1

Stack Overflow用户

发布于 2018-05-12 00:52:36

为每个条目添加xml声明和游戏、游戏标签。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
<games>
<game>
<systemMetadata>
          <title>Koha</title>...
</aboutRecord>
</game>
</games>

然后创建目录xsl表,如下所示:

代码语言:javascript
复制
   <?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>


    <xsl:for-each select="games/game">
    <h1><xsl:value-of select="systemMetadata/title"/></h1>
     <h3>by <xsl:value-of select="systemMetadata/creator"/></h3>
     <h3><xsl:value-of select="systemMetadata/subject"/></h3>
     <p>
     <xsl:value-of select="systemMetadata/title"/> <xsl:value-of select="systemMetadata/date"/>
     <xsl:value-of select="systemMetadata/type"/> <xsl:value-of select="systemMetadata/description"/>
     </p>
      <h2><xsl:value-of select="systemMetadata/rights"/></h2>
      <br/>
      <h2><i>Record created by <xsl:value-of select="aboutRecord/recordCreator"/> on 
      <xsl:value-of select="aboutRecord/creationDate"/></i></h2>

   </xsl:for-each>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50296185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档