zoukankan      html  css  js  c++  java
  • 用于解析 sina 新闻页面的 XSLT 文件

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
     <xsl:template match="/">
      <html>
       <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>Sina newsletter</title>
       </head>
       <body>
        <xsl:apply-templates select="html/body/div/table/tbody/tr/td/div[@id='article']"/>
       </body>
      </html>
     </xsl:template>
     
     <!-- 新闻内容 -->
     <xsl:template match="div">
     
      <!-- 新闻标题 -->
      <xsl:apply-templates select="table/tbody/tr/th/h1"/>
      
      <!-- 新闻的内容 -->
      <xsl:apply-templates select="table/tbody/tr/td"/>
     </xsl:template>
     
     <!-- 显示标题  -->
     <xsl:template match="h1">
      <h1>
       <xsl:value-of select="text()"/>
      </h1>
     </xsl:template>
     <!-- 显示段落 -->
     <xsl:template match="p">
      <p>
       <xsl:apply-templates />
      </p>
     </xsl:template>
     
     <!-- 显示内容中文字 -->
     <xsl:template match="text()">
      <xsl:value-of select="."/>
     </xsl:template>
     
    </xsl:stylesheet>
  • 相关阅读:
    人月神话读书笔记
    读人月神话有感
    Codeforces 137D
    Codeforces 1138B
    <WFU暑假训练一> 解题报告
    Codeforces 1250B
    Codeforces 1038D
    Codeforces 1202D
    Codeforces 87B
    Codeforces 208C
  • 原文地址:https://www.cnblogs.com/haogj/p/339145.html
Copyright © 2011-2022 走看看