I want to Transform xml using xslt and create new File instead of the set value xmlcontrol in Visual Studio. Below is My code. I need to create a new XML Transformed File Called tr.xml file in My root directory.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("hotels.xml"));
System.Xml.Xsl.XslTransform trans = new
System.Xml.Xsl.XslTransform();
trans.Load(Server.MapPath("hotel.xsl"));
Xml1.Document = doc;
Xml1.Transform = trans;
Can Any one please help on this??/
If you want to transform an input file to an output file with XSLT 1.0 in .NET 2.0 and later then you should use XslCompiledTransform
and it is as easy as
XslCompiledTransform proc = new XslCompiledTransform();
proc.Load(Server.MapPath("hotels.xsl"));
proc.Transform(Server.MapPath("hotels.xml"), Server.MapPath("tr.xml"));
See http://msdn.microsoft.com/en-us/library/0610k0w4.aspx for a detailed documentation of XslCompiledTransform
and its possible inputs and outputs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.