Created
July 9, 2014 06:44
-
-
Save arbaaz/8f691de3d5095e9848f5 to your computer and use it in GitHub Desktop.
Applying xslt on xml and storing in database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment