954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Insert multiple xml files in one table

Hi guys how can I insert multiple xml files in one table.
Thanks

sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

could you provide more information/example? This is really unclear.

PierlucSS
Junior Poster
187 posts since Feb 2010
Reputation Points: 65
Solved Threads: 30
 

i have 3 xml files and i want to insert them in database in one single table . Let me know what you dont understand.

sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

alright guys i got it.below is the way how you can achieve this

string myString = "";
            string sXMLFilePath = "C:\\Dict1.txt";
            XmlDocument document = new XmlDocument();

            document.Load(sXMLFilePath);
            XmlNodeList nodelist = document.SelectNodes("ArrayOfString/string");
            SqlConnection cn = new SqlConnection(@"Server=208.124.179.197;Database=RTLUser;UID=sa;");
            SqlDataAdapter da = new SqlDataAdapter();

            cn.Open();
            foreach (XmlNode node in nodelist)
            {
                string coll = node.InnerText.Replace("'","''");
                myString = @"INSERT INTO levelTbl(word,level)  Values('" + coll + "','" + "1" + "')";

                SqlCommand myCmd = new SqlCommand(myString, cn);
                myCmd.ExecuteNonQuery();

            }
sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You