• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

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.
0
sabrina_spillane
Asked:
sabrina_spillane
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now