<?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: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="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>
?<xsl:template match="p">
??<p>
???<xsl:apply-templates />
??</p>
?</xsl:template>
?
?<!-- 顯示內容中文字 -->
?<xsl:template match="text()">
??<xsl:value-of select="."/>
?</xsl:template>
?
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Sina newsletter</title>
</head>
<body/>
</html>
不知道怎么回事,我用的是新浪新聞頁面http://news.sina.com.cn/
換這個也一樣啊 這是今天的新聞
用這個信箱聯系我。
<!--
Translator: B.Armbruster Altova GmbH
XSLT2 translation of the XQuery use case
Filename: treeQ6.xsl
Section: 1.2.4.6 Q6
Purpose: Make a nested list of the section elements in Book1, preserving their original attributes and hierarchy. Inside each section element, include the title of the section and an element that includes the number of figures immediately contained in the section.
-->
<!--
XML Query Use Cases: http://www.w3.org/TR/xquery-use-cases/
Copyright 漏2003 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University). All Rights Reserved. This work is distributed under the W3C廬 Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn xsl">
<!--output format close to xquery-->
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
<xsl:template match="/html">
<news>
<xsl:apply-templates />
</news>
</xsl:template>
<xsl:template match="text()">
</xsl:template>
<xsl:template match="/html/body/div[3]/div[5]/div[1]/div[1]/div[1]">
<title>
<xsl:value-of select="h1[1]/text()"/>
</title>
<website>
<xsl:value-of select="div[1]/span[1]/a[1]/text()"/>
</website>
<date>
<xsl:value-of select="div[1]/span[2]/text()"/>
</date>
<field>
<xsl:value-of select="div[1]/span[3]/text()"/>
</field>
<content>
<xsl:value-of select="div[1]/following::*/text()"/>
</content>
</xsl:template>
</xsl:stylesheet>
共勉!