• <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>
            流量統(tǒng)計(jì):
            Rixu Blog (日需博客)
            日需博客,每日必需來踩踩哦..
            posts - 108,comments - 54,trackbacks - 0
            1.創(chuàng)建XSLT文件,定義格式;
            2.在C#中使用XslCompiledTransform對象的load()方法加載XSLT文件;
            3.使用Transform()方法轉(zhuǎn)換XML文檔。

            實(shí)例:將books.xml按照books.xsl定義的格式轉(zhuǎn)換成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    
            本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            posted on 2011-08-15 09:53 日需博客 閱讀(858) 評論(0)  編輯 收藏 引用 所屬分類: C#Windows技術(shù)文章轉(zhuǎn)載
            欧美久久一区二区三区| 久久青草国产精品一区| 欧美日韩精品久久久久| 亚洲国产成人久久一区久久| 亚洲成av人片不卡无码久久| 国内精品伊人久久久久777| 日韩人妻无码精品久久久不卡| 国产精品岛国久久久久| 精品无码人妻久久久久久| 亚洲国产精品综合久久网络| 久久久免费精品re6| 久久精品国产只有精品66| 久久精品国产2020| 亚洲国产精品一区二区久久| 尹人香蕉久久99天天拍| 久久午夜无码鲁丝片| 国产巨作麻豆欧美亚洲综合久久| 久久婷婷五月综合色奶水99啪| A狠狠久久蜜臀婷色中文网| 亚洲欧美国产日韩综合久久| 久久国产精品无码一区二区三区| 国产一区二区精品久久岳| 久久精品国产精品亚洲精品 | 国内精品伊人久久久影院| 热re99久久6国产精品免费| 国产精品一区二区久久精品无码 | 四虎国产精品免费久久5151| 亚洲日本久久久午夜精品| 国产精品久久久久久久久鸭 | 国产精品久久久久影院嫩草| 亚洲色欲久久久久综合网| 青青国产成人久久91网| 久久精品国产男包| 人妻无码精品久久亚瑟影视| 久久国产免费观看精品| 久久天天躁狠狠躁夜夜96流白浆 | 亚洲国产精品久久久久网站| 亚洲av日韩精品久久久久久a| 日本欧美国产精品第一页久久| 国产精品久久久久9999| 久久亚洲日韩精品一区二区三区|