sabrina_spillane
asked on
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.
ASKER
Where does this code go, is it in the code behind or in the XML Document. Thanks for the above.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
I use a web form (aspx page) and then this goes in the code behind (aspx.cs)
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.MapPa
XslTransform xslt = new XslTransform();
xslt.Load(Page.Server.MapP
StringWriter sw = new StringWriter();
XPathNavigator nav = doc.DocumentElement.Create
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.