• <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 (日需博客)
            日需博客,每日必需來(lái)踩踩哦..
            posts - 108,comments - 54,trackbacks - 0
            1.創(chuàng)建XSLT文件,定義格式;
            2.在C#中使用XslCompiledTransform對(duì)象的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)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            posted on 2011-08-15 09:53 日需博客 閱讀(864) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): C#Windows技術(shù)文章轉(zhuǎn)載
            久久本道综合久久伊人| 99久久国产精品免费一区二区| 久久青青草原亚洲av无码app| 色综合久久久久综合体桃花网| 婷婷久久久亚洲欧洲日产国码AV | 久久青青草原精品国产不卡| 久久久久久久久66精品片| 久久天天躁狠狠躁夜夜躁2O2O| 久久久中文字幕| 日产精品久久久久久久| 免费观看成人久久网免费观看| 久久免费99精品国产自在现线| 综合久久一区二区三区 | 久久综合久久鬼色| 久久精品aⅴ无码中文字字幕不卡| 久久精品国产亚洲av影院| 久久青青草原精品国产软件| 久久亚洲私人国产精品| 亚洲国产天堂久久久久久| 丰满少妇人妻久久久久久4| 人妻无码久久一区二区三区免费 | 久久99九九国产免费看小说| 麻豆精品久久精品色综合| 亚洲va久久久噜噜噜久久| 亚洲国产成人久久一区WWW| 久久99国产精品久久久| 日韩AV无码久久一区二区| 久久无码中文字幕东京热| 久久久久这里只有精品| 伊人热人久久中文字幕| 久久久久免费看成人影片| 色综合久久久久无码专区| 久久精品国产亚洲AV忘忧草18| 色婷婷噜噜久久国产精品12p| 曰曰摸天天摸人人看久久久| 日本一区精品久久久久影院| 久久香蕉一级毛片| 成人午夜精品久久久久久久小说| 久久国产色AV免费看| 成人久久精品一区二区三区| AAA级久久久精品无码片|