I have the following nested level XML file which I want to store in sql2005 database by C# :

 

 

    379x573t8756k8065

    888888

   

        1

        One Lot

        25.0

        1

        <o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        <![CDATA[<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        Lot 1<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        ]]><o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">       

       

       

        LOT LOT 1

        ]]>

       

       

       

        Lot 1

        ]]>

       

       

       

        LOT LOT 1

        ]]>

       

       

       

       

   

   

        2

        One Lot

        25.0

        1

        <o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        <![CDATA[<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        Lot 2<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">        ]]><o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">       

       

       

        LOT LOT 2

        ]]>

       

       

       

        Lot 2

        ]]>

       

       

       

        LOT LOT 2

        ]]>

       

       

       

       

   

 

I wrote the code like this:

 

 

using (SqlConnection conn = new SqlConnection(connectionInfo))

            {

                // Try with sql bulk copy

 

                DataSet ds = new DataSet();

 

                StringBuilder s = new StringBuilder(); 

              s.Append("\n");

              s.Append("\n");    

              s.Append("379x573t8756k8065\n");

              s.Append("888888\n");

              s.Append("\n");

               s.Append("1\n");

              s.Append("One Lot\n");

              s.Append("25.0\n");

              s.Append("1\n");

              s.Append("\n"</SPAN>);<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">               s.Append(<SPAN style="COLOR: #a31515">"<![CDATA[ Lot 1    ]]>\n"</SPAN>);<o:p></o:p></SPAN></P> <P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">                s.Append(<SPAN style="COLOR: #a31515">" \n");

                s.Append("\n");

               s.Append("\n");

                s.Append(" \n");

                s.Append("\n");

               s.Append("\n");

                s.Append(" \n");

                s.Append("\n");

               s.Append("\n");

                s.Append(" \n");

                 s.Append(" \n");

 

              s.Append("");

              s.Append(""); 

               

              String xmlString = s.ToString();

 

              // Create an XmlReader

              XmlReader reader = XmlReader.Create(new StringReader(xmlString));

 

              ds.ReadXml(reader);

 

            BUT it is filling only top 3 level node of data ID , AUCTION_ID , INVENTORY_ID …not the nested level data

 

 

SqlConnection connection = new SqlConnection(connectionInfo);

                SqlBulkCopy sbc = new SqlBulkCopy(connection);

                sbc.DestinationTableName = "BidInventory";

 

connection.Open();

 

                //table 0 is the main table in this dataset

                sbc.WriteToServer(ds.Tables[0]);

                connection.Close();

 

I tried to pass the file with full path like ds.ReadXml(("C:\\AuctionNetwork\\Message.xml");

 

But the result is the same…

 

Can you please guide me how can I the whole xml data in my dataset or is there any other way of doing it.

 

 

Please help