Applying xslt on xml and storing in database
using System.Data;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
namespace xmltodb
{
internal static class Program
{
private static void Main(string[] args)
{
const string myXmlFile = @"E:\DHl\O2C_I035_CDM_Incoming.xml";
const string myStyleSheet = @"E:\DHl\dhl.xsl";
var xtr = new XmlTextReader(myXmlFile) {WhitespaceHandling = WhitespaceHandling.None};
var xd = new XmlDocument();
xd.Load(xtr);
var xslt = new XslCompiledTransform();
xslt.Load(myStyleSheet);
string output;
using (var writer = new StringWriter())
{
xslt.Transform(xd.CreateNavigator(), null, writer);
output = writer.ToString();
}
var ds = new DataSet();
ds.ReadXml(new StringReader(output));
xtr.Close();
// Console.ReadKey();
}
}
}