コード例 #1
0
        public static void ConvertTables(String xmlInputFilePath, String outputDirectory)
        {
            var converter = new XmlToCsvUsingDataSet(xmlInputFilePath);
            var context = new XmlToCsvContext(converter);

            foreach (string xmlTableName in context.Strategy.TableNameCollection)
            {
                context.Execute(xmlTableName, outputDirectory + "/" + xmlTableName + ".csv", Encoding.Default);
            }
        }
コード例 #2
0
ファイル: XmlToCsvTests.cs プロジェクト: Groostav/XmlToCsv
 public void LinqImplementationTest()
 {
     const string path = @"data.xml";
     var converter = new XmlToCsvUsingLinq(path);
     var context = new XmlToCsvContext(converter);
     Assert.AreEqual(1, context.Strategy.TableNameCollection.Count);
     foreach (string xmlTableName in context.Strategy.TableNameCollection)
     {
         context.Execute(xmlTableName, @"dataLinq_" + xmlTableName + ".csv", Encoding.Default);
     }
 }
コード例 #3
0
ファイル: XmlToCsvTests.cs プロジェクト: Groostav/XmlToCsv
 public void CanReadAttributeTest()
 {
     const string path = @"DataWithAttributes.xml";
     var converter = new XmlToCsvUsingDataSet(path);
     var context = new XmlToCsvContext(converter);
     Assert.AreEqual(2, context.Strategy.TableNameCollection.Count);
     foreach (string xmlTableName in context.Strategy.TableNameCollection)
     {
         context.Execute(xmlTableName, @"dataDataSet_" + xmlTableName + ".csv", Encoding.Default);
     }
 }
コード例 #4
0
ファイル: XmlToCsvTests.cs プロジェクト: Groostav/XmlToCsv
        public void DuplicateNameRenamedTest()
        {
            const string path = @"ErrorDuplicateName.xml";
            var converter = new XmlToCsvUsingDataSet(path, true);
            var context = new XmlToCsvContext(converter);
            Assert.AreEqual(2, context.Strategy.TableNameCollection.Count);

            foreach (string xmlTableName in context.Strategy.TableNameCollection)
            {
                context.Execute(xmlTableName, @"ErrorDuplicateName_" + xmlTableName + ".csv", Encoding.Default);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Groostav/XmlToCsv
        /// <summary>
        /// XML to CSV Command Line Converter. User as follows: XmlToCsv.Console.exe -xml C:\payslip.xml -dir C:\my_output
        /// </summary>
        /// <param name="args">First parameter selects the XML file, second parameter specifies the output directory.</param>
        static void Main(string[] args)
        {
            //Command line parsing library from http://cmdline.codeplex.com/
            var cmd = new ConsoleCmdLine();
            var xmlInputFilePath = new CmdLineString("xml", true, "XML file to convert.");
            var outputDirectory = new CmdLineString("dir", true, "Directory to save the CSV result to.");

            cmd.RegisterParameter(xmlInputFilePath);
            cmd.RegisterParameter(outputDirectory);
            cmd.Parse(args);

            var converter = new XmlToCsvUsingDataSet(xmlInputFilePath.Value);
            var context = new XmlToCsvContext(converter);

            foreach (string xmlTableName in context.Strategy.TableNameCollection)
            {
                context.Execute(xmlTableName, outputDirectory.Value + @"\" + xmlTableName + ".csv", Encoding.Unicode);
            }
        }