XML and XSLT transformation using C#.NET

With XML Document you can illustrate data hierarchically without caring about the later output format, and with XSL-Transformations you have the ability to convert the data content of that XML document into various formats such as text, xml, html etc. XSLT, the extensible style sheet language for transformations, is a language that provides the mechanism to transform and manipulate XML data. It is used to transform XML documents into another documents, for example other XML document, HTML document or text document. XSLT processors parse the input XML document, as well as the XSLT style sheet and then process the instructions found in the XSLT style sheet, using the elements from input XML document.

Here in this sample I have explained you the XML and XSLT transformation using C#.NET 2.0.
C#.NET 2.0. Before transformation my tool will look like this...








After you select your XSLT and XML files when you click on the preview button the output is displayed as HTML in the webBrowser control.



For more see the sample code...


XPathDocument xmlFileDoc = new XPathDocument(txtxmlfilepath.Text.ToString());
XmlTextWriter myWriter = new XmlTextWriter("result.html", null);
XslCompiledTransform XSLpreview = new XslCompiledTransform();
XSLpreview.Load(txtxslfilepath.Text.ToString());
XSLpreview.Transform(xmlFileDoc, null, myWriter);
myWriter.Close();
webBrowser1.Navigate(@"C:\result.html");

Download The Sample Solution

Comments

Popular posts from this blog

ASP.NET website "Cannot read configuration file due to insufficient permissions" in IIS 7 and Windows Server 2008

Error occurred in deployment step 'Install app for SharePoint': The System Account cannot perform this action.

None of the selected features can be installed or upgraded. Setup cannot proceed since no