• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            流量統計:
            Rixu Blog (日需博客)
            日需博客,每日必需來踩踩哦..
            posts - 108,comments - 54,trackbacks - 0
            1.創建XSLT文件,定義格式;
            2.在C#中使用XslCompiledTransform對象的load()方法加載XSLT文件;
            3.使用Transform()方法轉換XML文檔。

            實例:將books.xml按照books.xsl定義的格式轉換成out.html
            TestXsl.cs:
            using System;
            using System.Xml.Xsl;

            namespace Magci.Test.XML.TestXsl
            {
            class Program
            {
            static void Main(string[] args)
            {
            XslCompiledTransform trans
            = new XslCompiledTransform();
            trans.Load(
            @"..\..\books.xsl");
            trans.Transform(
            @"..\..\books.xml", "out.html");
            }
            }
            }

            books.xml:

            <?xml version="1.0" encoding="utf-8" ?>
            <bookstore>
            <book genre="autobiography" publicationdate="1991" ISBN="1-861003-11-0">
            <title>The Autobiography of Benjamin Franklin</title>
            <author>
            <first-name>Benjamin</first-name>
            <last-name>Franklin</last-name>
            </author>
            <price>8.99</price>
            </book>
            <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
            <title>The Confidence Man</title>
            <author>
            <first-name>Herman</first-name>
            <last-name>Melville</last-name>
            </author>
            <price>11.99</price>
            </book>
            <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
            <title>The Gorgias</title>
            <author>
            <name>Plato</name>
            </author>
            <price>9.99</price>
            </book>
            </bookstore>

            books.xsl:

            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:template match="/">
            <HTML>
            <head>
            <title>Price List</title>
            </head>
            <body>
            <table>
            <xsl:apply-templates/>
            </table>
            </body>
            </HTML>
            </xsl:template>

            <xsl:template match="bookstore">
            <xsl:apply-templates select="book"/>
            </xsl:template>

            <xsl:template match="book">
            <tr>
            <td>
            <xsl:value-of select="title"/>
            </td>
            <td>
            <xsl:value-of select="price"/>
            </td>
            </tr>
            </xsl:template>
            </xsl:stylesheet>

            out.html:

            <HTML>
            <head>
            <META http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Price List</title>
            </head>
            <body>
            <table>
            <tr>
            <td>The Autobiography of Benjamin Franklin</td>
            <td>8.99</td>
            </tr>
            <tr>
            <td>The Confidence Man</td>
            <td>11.99</td>
            </tr>
            <tr>
            <td>The Gorgias</td>
            <td>9.99</td>
            </tr>
            </table>
            </body>
            </HTML>
            Logo
            作者:Gezidan
            出處:http://www.rixu.net    
            本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
            posted on 2011-08-15 09:53 日需博客 閱讀(863) 評論(0)  編輯 收藏 引用 所屬分類: C#Windows技術文章轉載
            欧美一区二区精品久久| 日韩乱码人妻无码中文字幕久久 | 久久香蕉超碰97国产精品| 久久精品无码一区二区WWW| 久久91精品国产91久| 亚洲国产精品高清久久久| av无码久久久久久不卡网站| 91精品国产91热久久久久福利 | 久久99精品国产| 久久只有这精品99| 久久91亚洲人成电影网站| 久久夜色撩人精品国产| 韩国免费A级毛片久久| 一本一本久久a久久精品综合麻豆| 麻豆一区二区99久久久久| 久久综合成人网| 精品久久久久久成人AV| 久久这里有精品| 久久国产福利免费| …久久精品99久久香蕉国产| 久久国产AVJUST麻豆| 91久久福利国产成人精品| 久久99精品国产自在现线小黄鸭 | 久久亚洲精品人成综合网| 亚洲精品tv久久久久久久久久| www久久久天天com| 久久久久人妻精品一区二区三区| 久久久久亚洲精品无码网址 | 东方aⅴ免费观看久久av| 久久久久久毛片免费看| 精品99久久aaa一级毛片| 国产成人无码精品久久久免费| 99久久无码一区人妻a黑| 高清免费久久午夜精品| 久久A级毛片免费观看| 粉嫩小泬无遮挡久久久久久| 国产精品久久久久影院色| 国产成人久久精品一区二区三区 | 久久精品亚洲精品国产欧美| 91精品观看91久久久久久| 久久www免费人成看国产片|