Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从XML到HTML的XSLT输出_Xml_Xslt - Fatal编程技术网

从XML到HTML的XSLT输出

从XML到HTML的XSLT输出,xml,xslt,Xml,Xslt,我有这样的XML <item> <title>Fastfood</title> <description><![CDATA[<p> <b> For more info, visit us </b><a href ="www.website.com">www.website.com</a></p> ]]></description> <lin

我有这样的XML

<item>
<title>Fastfood</title>
<description><![CDATA[<p>
<b> For more info, visit us </b><a href ="www.website.com">www.website.com</a></p>
  ]]></description>
  <link>http://www.website.com/</link>
  <author>TCPC</author>
  <guid  isPermaLink="false">a57c770b-a85d-437f-aceb-fd0fc3a0bfb2</guid>
  <pubDate>Mon, 25 Nov 2013 15:39:48 GMT</pubDate>
  <enclosure url="http://www.website.com/images/logo.jpg" type="image/jpeg" length="16645" />
  </item>
  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 10"> <!--Displays only 10 entries-->

      <div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
        <span style="font-weight:bold; font-size: 1.5em;">
          <a id ="{author}"></a>
          <xsl:value-of select="title"/>
        </span>
      </div>
      <div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
        <br></br>
        <h6 style="font-style:italic">
          <xsl:value-of select="pubDate"/>
        </h6>
        <br></br>
        <span style ="font: normal 14px/1.5 'Segoe UI'">
          <xsl:value-of select="description" />
        </span>
        <br></br>
      </div>
    </xsl:if>
  </xsl:for-each>
  <br></br>
  <hr></hr>
</html>

快餐
欲了解更多信息,请访问我们

  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 10"> <!--Displays only 10 entries-->

      <div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
        <span style="font-weight:bold; font-size: 1.5em;">
          <a id ="{author}"></a>
          <xsl:value-of select="title"/>
        </span>
      </div>
      <div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
        <br></br>
        <h6 style="font-style:italic">
          <xsl:value-of select="pubDate"/>
        </h6>
        <br></br>
        <span style ="font: normal 14px/1.5 'Segoe UI'">
          <xsl:value-of select="description" />
        </span>
        <br></br>
      </div>
    </xsl:if>
  </xsl:for-each>
  <br></br>
  <hr></hr>
</html>
]]> http://www.website.com/

  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 10"> <!--Displays only 10 entries-->

      <div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
        <span style="font-weight:bold; font-size: 1.5em;">
          <a id ="{author}"></a>
          <xsl:value-of select="title"/>
        </span>
      </div>
      <div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
        <br></br>
        <h6 style="font-style:italic">
          <xsl:value-of select="pubDate"/>
        </h6>
        <br></br>
        <span style ="font: normal 14px/1.5 'Segoe UI'">
          <xsl:value-of select="description" />
        </span>
        <br></br>
      </div>
    </xsl:if>
  </xsl:for-each>
  <br></br>
  <hr></hr>
</html>
您应该更改

  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 10"> <!--Displays only 10 entries-->

      <div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
        <span style="font-weight:bold; font-size: 1.5em;">
          <a id ="{author}"></a>
          <xsl:value-of select="title"/>
        </span>
      </div>
      <div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
        <br></br>
        <h6 style="font-style:italic">
          <xsl:value-of select="pubDate"/>
        </h6>
        <br></br>
        <span style ="font: normal 14px/1.5 'Segoe UI'">
          <xsl:value-of select="description" />
        </span>
        <br></br>
      </div>
    </xsl:if>
  </xsl:for-each>
  <br></br>
  <hr></hr>
</html>
<span style ="font: normal 14px/1.5 'Segoe UI'">
    <xsl:value-of select="description" />
</span>>

>

  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 10"> <!--Displays only 10 entries-->

      <div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
        <span style="font-weight:bold; font-size: 1.5em;">
          <a id ="{author}"></a>
          <xsl:value-of select="title"/>
        </span>
      </div>
      <div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
        <br></br>
        <h6 style="font-style:italic">
          <xsl:value-of select="pubDate"/>
        </h6>
        <br></br>
        <span style ="font: normal 14px/1.5 'Segoe UI'">
          <xsl:value-of select="description" />
        </span>
        <br></br>
      </div>
    </xsl:if>
  </xsl:for-each>
  <br></br>
  <hr></hr>
</html>


您可以将
禁用输出转义=“yes”
添加到
元素中。也就是说,将
元素放在
中看起来不是一个好主意,您可能应该使用
来代替。可能的重复项我无法控制XML文件。谢谢,这很有效