XML
  Home arrow XML arrow Page 3 - Applying XSLT to XML Using ASP.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Applying XSLT to XML Using ASP.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 62
    2004-09-13

    Table of Contents:
  • Applying XSLT to XML Using ASP.NET
  • A Simple Example on XSLT
  • XSLT with ASP.NET
  • Query a Database and Transform through XSLT using ASP.NET
  • How to Transform More than One Row?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Applying XSLT to XML Using ASP.NET - XSLT with ASP.NET


    (Page 3 of 5 )

    The above example works well with IE6 or other latest browsers (which support XSLT), but what about the situation of old browsers? Our sample example would never work on those browsers. To overcome this problem, we shift XML and XSLT to the server side programming that supports these technologies. One of them is ASP.NET. I further extend the previous sample example with respect to ASP.NET using a simple web form with few lines of ASP.NET code.

    Open your Visual Studio.NET and create a new ASP.NET project. Add the above two files (sample1.xml and sample1.xslt) to the project. Drag an XML control from toolbox on to the webform. Press F7 (code window) and copy the following two statements at the top:

    Imports System.Xml
    Imports System.Xml.Xsl

    Copy the following code in the page load event of that webform.

    Dim docXML As New XmlDocument
          docXML.Load(Server.MapPath("sample1.xml"))
          Dim docXSL As New XslTransform
          docXSL.Load(Server.MapPath("sample1.xslt"))
          Xml1.Document = docXML
          Xml1.Transform = docXSL

    I think the above code is self-explanatory. Basically, we are creating two objects ‘docXML’ (to hold an XML document) and ‘docXSL’ (to hold an XSL document). Using the ‘Load’ method, we are loading the two files in to the respective objects. We assign both of them to the XML server control (xml1) provided in ASP.NET. The transformation gets implemented automatically at run-time without any extra hurdle!!

    Press F5 to execute the web application and you should be able to see the same output to which you have seen earlier. By now, we designed a web application using XML and XSLT, which is completely browser independent.

    But, always designing static XML documents may not be helpful in all the situations. What if I want to have a dynamically generated XML to be transformed through XSLT? The next section addresses this issue in a very pleasant manner.

    More XML Articles
    More By Jagadish Chaterjee


       · this article help intermediates to know about the power of xml using xls.can help...
     

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT