Upload data from multiple xml files to SharePoint

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Data;

namespace XML.Migration
{
    class Program
    {
        static void Main(string[] args)
        {
            //Provide the path of the lotus notes xml files
            string directoryPath = @”C:\Path”;

            //It cheque if the folder exisits
            if (Directory.Exists(directoryPath))
            {
                try
                {
                    //Read all the file name and path
                    string[] files = Directory.GetFiles(directoryPath);
                    //cheque if files exists
                    if (files.Length > 0)
                    {
                        //loop all the files
                        for (int i = 0; i < files.Length; i++)
                        {
                            //Get the fle name
                            string text4 = files[i];
                            //cheque if the xml files exists in the folder.
                            if (Path.GetExtension(text4).ToLower().Equals(“.xml”))
                            {
                                XmlDocument doc = new XmlDocument();
                                //Read the xml document.
                                doc.Load(text4);

                                //Loop all the xml nodes inside the xml files
                                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                                {
                                    //Print the tppGrossMargin node value.
                                    Console.WriteLine(node[“tppGrossMargin”].Name.ToString() + ” – ” + node[“tppGrossMargin”].InnerText.ToString());
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(“Migration Error Message:- ” + ex.Message.ToString() +”\n”);
                }
            }
            Console.ReadKey();
        }
    }
}

About Navdeep Madan

Working as a sharepoint, web solution consultant
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment