Creating a reports as a WebPage using XML and XSL? How should this be implemented?

Posted on 2006-03-23
Last Modified: 2010-04-16
I am not too sure the best approach to this but here goes. I have a crystal report and i need to put it on the web. I am wondering if I just create a web control and design it like the report and then use XML and XSL to have the report generated. I am not too sure where to start with this though, can anyone give me any pointers on how to go about this from creating the web control in .Net to implementing XML and XSL which I have never used? Thanks in advance for all the help.
Question by:sabrina_spillane
    LVL 35

    Expert Comment

    I can help with part only.

    To apply the xsl or xslt file to the xml file you would use the following code:

    // Define an XML object
    XmlDocument doc = new XmlDocument();

    // Load the xml document

    XslTransform xslt = new XslTransform();

    StringWriter sw = new StringWriter();
    XPathNavigator nav = doc.DocumentElement.CreateNavigator();
    xslt.Transform(nav, null, sw, null);

    Now the contents are in sw.  You can convert back to an XML file with this:

    XmlDocument xmlOut = new XmlDocument();

    Or you could simply output to the webpage with this:


    or whatever else you wanted to do with it after the transformation has been applied.

    Author Comment

    Where does this code go, is it in the code behind or in the XML Document. Thanks for the above.
    LVL 35

    Accepted Solution

    This is in the code behind in your C# page.  Notice that it loads the xml document, then applies the xsl file, then you can do what you want with the output.

    Author Comment

    So would I add a Web form or a Web Control to my current project for this? Would it be a Web Control and then add from mt toolbox the XML Control?
    LVL 35

    Expert Comment

    I use a web form (aspx page) and then this goes in the code behind (aspx.cs)

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now