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

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.
sabrina_spillaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrichmonCommented:
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
doc.Load(Page.Server.MapPath("YourXMLfile.xml"));

XslTransform xslt = new XslTransform();
xslt.Load(Page.Server.MapPath("YourXSLfile.xslt"));

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();
xmlOut.LoadXml(sw.ToString());

Or you could simply output to the webpage with this:

Response.Write(sw.ToString());

or whatever else you wanted to do with it after the transformation has been applied.
0
sabrina_spillaneAuthor Commented:
Where does this code go, is it in the code behind or in the XML Document. Thanks for the above.
0
mrichmonCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sabrina_spillaneAuthor Commented:
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?
0
mrichmonCommented:
I use a web form (aspx page) and then this goes in the code behind (aspx.cs)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.