| Author: Sajid P K 03 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
pls chk
The steps to transform an Xml document are
1) Load the Xml document XPathDocument myXPathDoc = new XPathDocument(<xml file path>) ;
2) Load the Xsl file XslTransform myXslTrans = new XslTransform() ; myXslTrans.Load(<xsl file path>);
3) Create a stream for output XmlTextWriter myWriter = new XmlTextWriter("result.html",null) ;
4) Perform the actual transformation myXslTrans.Transform(myXPathDoc,null,myWriter) ;
Do not forget to Rate the post... Regards, Sajid P K
|
| Author: Robin Thomas 03 Jul 2009 | Member Level: Gold | Rating:   Points: 3 |
I think you are confused with the use of XSLT. You are not "sending " data to XSLT. You are using XSLT to transform the XML into a different format.
What "saji" described is the perfect method for doing that. But just a small correction. Instead of XslTransform you can use XslCompiledTransform because XslTransform is deprecated. Try this private static string TranformXML(string xmlFile , string xsltFile) {
StringBuilder resultString = new StringBuilder();
string FilePath = HttpContext.Current.Server.MapPath(XsltFolderPath + System.IO.Path.DirectorySeparatorChar + xsltFile).ToString();
//create an XPathDocument using the reader from the XML string MemoryStream m = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(xmlFile));
XPathDocument xpathDoc = new XPathDocument(new StreamReader(m));
//Create the new transform object
XslCompiledTransform transform = new XslCompiledTransform();
//String to store the resulting transformed XML (Excel file)
XmlWriter writer = XmlWriter.Create(resultString);
transform.Load(FilePath); //Loading XSLT file. transform.Transform(xpathDoc, writer); //Transforming the XML file
return resultString.ToString();
}
Robin Thomas Freelancer visit for fresher jobs
|
| Author: Sajid P K 03 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
http://www.dotnetspider.com/resources/29895-XML-HTML-transformation-using-Xslt.aspx
Do not forget to Rate the post... Regards, Sajid P K
|
| Author: kumar 03 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi Robin Thomas your code works fine for me thank you
|