asp:TreeView binded to XML transformation data : XML TreeView « XML « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.Net » XML » XML TreeView 
asp:TreeView binded to XML transformation data

<%--
Code Revised from
       
Professional ASP.NET 2.0 XML (Programmer to Programmer) (Paperback)
by Thiru Thangarathinam 

# Publisher: Wrox (January 182006)
# Language: English
# ISBN: 0764596772
--%>       

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Applying XSL Transformation on an XmlDataSource Control</title>
</head>
<body>    
    <form id="form1" runat="server">
    <div>
      <asp:TreeView ID="TreeView1" Runat="server" 
            DataSourceID="XmlDataSource1" />
      <asp:XmlDataSource ID="XmlDataSource1" Runat="server" 
        DataFile="Bookstore.xml"
        TransformFile="Bookstore.xsl" />
    </div>
    </form>
</body>
</html>


<%--
<bookstore>
  <genre name="Fiction">
    <book ISBN="10-861003-324" Title="title 1" Price="19.99">
      <chapter num="1" name="Introduction">
        A
      </chapter>
      <chapter num="2" name="Body">
        B
      </chapter>
      <chapter num="3" name="Conclusion">
        C
      </chapter>
    </book>
    <book ISBN="1-861001-57-5" Title="title " Price="24.95">
      <chapter num="1" name="Introduction">
        D
      </chapter>
      <chapter num="2" name="Body">
        E
      </chapter>
      <chapter num="3" name="Conclusion">
        F
      </chapter>
    </book>   
  </genre>
  <genre name="NonFiction">
    <book ISBN="10-861003-324" Title="title 2" Price="19.99">
      <chapter num="1" name="Introduction">
        G
      </chapter>
      <chapter num="2" name="Body">
        H
      </chapter>
      <chapter num="3" name="Conclusion">
        I
      </chapter>
    </book>   
    <book ISBN="1-861001-57-6" Title="title 3" Price="27.95">
      <chapter num="1" name="Introduction">
        J
      </chapter>
      <chapter num="2" name="Body">
        K
      </chapter>
      <chapter num="3" name="Conclusion">
        L
      </chapter>
    </book>
  </genre>
</bookstore>
--%>


<%--
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

  <xsl:template match="genre">
    <genre>
      <xsl:attribute name="name">
        <xsl:value-of select="@name"/>
      </xsl:attribute>
      <xsl:apply-templates select="book"/>
    </genre>
  </xsl:template>

  <xsl:template match="book">
    <book>
      <xsl:attribute name="ISBN">
        <xsl:value-of select="@ISBN"/>
      </xsl:attribute>
      <xsl:element name="title">
        <xsl:value-of select="title"/>
      </xsl:element>
      <xsl:element name="price">
        <xsl:value-of select="price"/>
      </xsl:element>
      <xsl:apply-templates select="chapters/chapter" />
    </book>
  </xsl:template>

  <xsl:template match="chapter">
    <chapter>
      <xsl:attribute name="num">
        <xsl:value-of select="@num"/>
      </xsl:attribute>
      <xsl:attribute name="name">
        <xsl:value-of select="@name"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </chapter>
  </xsl:template>

</xsl:stylesheet>


--%>       
           
       
Related examples in the same category
1. Build tree out of the XML data file
2. Bind inline XML datasource to asp treeview
3. asp TreeView data binding to XML data
w_w___w__._j_ava_2___s___.__c__o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.