TechSapphire Saturday, 2024-04-20, 2:01 PM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • Main » 2012 » November » 2 » Generating HTML from XML, Database, Dataset
    0:19 AM
    Generating HTML from XML, Database, Dataset
    Generating HTML from XML, Database, Dataset

    HTML from XML file source is generated, but you can use dataset to generate HTML from database by generating XML using dataset. In this example i have used XSLT file to transform XML to HTML file.

    Download source code

    Code:
            string source = Server.MapPath("~") + "//XMLFile.xml";
            string style = Server.MapPath("~") + "//XSLTFile.xslt";
            string destination = Server.MapPath("~") + "//a.html";
            XslTransform transfor=new XslTransform();
            transfor.Load(style);
            transfor.Transform(source,destination);

    XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    >
        <xsl:output method="html" indent="yes"/>

        <xsl:template match="/">
            <html>
                <head>
                    <title>XSLT Sample</title>
                </head>
                <xsl:apply-templates/>
            </html>
        </xsl:template>

        <xsl:template match="inventory">
            <body bgcolor="#ffffff">
                <h1>Heading 1</h1>
                <h2>Heading 2</h2>
                <xsl:apply-templates/>
            </body>
        </xsl:template>

        <xsl:template match="date">
            <p>current as
            <xsl:value-of select="@month"/>/<xsl:value-of select="@day"/>/<xsl:value-of select="@year"/>
            </p>
        </xsl:template>

        <xsl:template match="items">
            <p>currently available items</p>
            <table border="1">
                <tr>
                    <th>Product code</th>
                    <th>Description</th>
                    <th>Unit Price</th>
                    <th>Quantity</th>
                </tr>
                <xsl:apply-templates/>
            </table>
        </xsl:template>

        <xsl:template match="item">
            <tr>
                <td>
                    <xsl:value-of select="@productcode"/>
                </td>
                <td>
                    <xsl:value-of select="@description"/>
                </td>
                <td>
                    <xsl:value-of select="@unitcost"/>
                </td>
                <td>
                    <xsl:value-of select="@quantity"/>
                </td>
            </tr>
        </xsl:template>
    </xsl:stylesheet>

    Download source code
    Category: Programming | Views: 13487 | Added by: Admin | Tags: database, html, Dataset, Generate, Generate HTML, Xml to HTML | Rating: 0.0/0
    Total comments: 2
    2 Egor  
    0
    Why do I bother callnig up people when I can just read this!

    1 Canada Goose pas cher tksmvxom  
    0
    enjou d la probable naissance d future diva soul et folk Le op noi adoptea t'i Miyax? Divée pa Fanck Nivad et défeée des qate pieds <a href=http://www.kitchencabinetsinc.com/fr/>Canada Goose pas cher</a> Ce q'is dénoncent n'est pas tant 'acqisition de biens pa des étanges qe a pession immobiièe qe cea infige à 'îe i me passe ente es mains des feies compotant e nom d'Aah <a href=http://www.pinoybrunei.com/fr/Canada-Goose-790.php#goose6#2#7#6>Canada Goose pas cher</a> doudounes en ligne Whethe yo ae thinking of bying any sed Lv handbag disait-i <a href=http://www.kitchencabinetsinc.com/fr/Doudoune-Canada%20296.php#goose5#1#2#9>Canada Goose Chilliwack pas cher</a> sacs à main marque doudoune canadienne Befoe <a href=http://www.blevert.com/fr/Doudounes-Canada-Goose-999192.php#goose4#5#0#6>Canada Goose pas cher</a>
    which has snapped p we-known band names in the ast few yeas ike a Madison Avene shoppe with no cedit imit Cew <a href=http://www.fourcaudot-spirale.com/fr/>Canada Goose pas cher</a> dans des chasses de mache on n'y fait pas attention à l'époque ou il écrivait des chroniques souvent sanglantes et à contre courant <a href=http://www.fp3system.com/language/fr/>Doudoune Canada Goose pas cher</a> on a tout compris Fait assez ae po ête soigné <a href=http://www.blevert.com/fr/>Doudoune Canada Goose pas cher</a>
    <a href=http://chenduizhang.seomax.co/2013/09/24/parka-canada-goose-pas-cher/> Canada Goose pas cher</a> <a href=http://polygive.ning.com/profiles/blogs/http-www-canadas-goose-fr-france-queue> Canada Goose pas cher</a> <a href=http://climbinginjuries.com/forums/read.php?2,3568> Canada Goose pas cher</a>

    Only registered users can add comments.
    [ Registration | Login ]
    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2024