Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a xml file. I wann read this xml file in dataset. but arise this error.

"Nested table 'link' which inherits its namespace cannot have multiple parent tables in different namespaces. "

Please help me
Posted

1 solution

C#
string xmlFile = "Data.xml";

DataSet dataSet = new DataSet();
dataSet.ReadXml(xmlFile, XmlReadMode.InferSchema);



//you can read using
C#
foreach (DataTable table in dataSet.Tables)
          {
              Console.WriteLine(table);
              for (int i = 0; i < table.Columns.Count; ++i)
                  Console.Write("\t" + table.Columns[i].ColumnName.Substring(0, Math.Min(6, table.Columns[i].ColumnName.Length)));
              Console.WriteLine();
              foreach (var row in table.AsEnumerable())
              {
                  for (int i = 0; i < table.Columns.Count; ++i)
                  {
                      Console.Write("\t" + row[i]);
                  }
                  Console.WriteLine();
              }
          }
 
Share this answer
 
v2
Comments
nitin.bhardwaj999 8-May-14 3:34am    
Sorry I have already try.
Vi(ky 8-May-14 4:13am    
it's work. check the update code
nitin.bhardwaj999 8-May-14 4:15am    
xml file is not read in dataset. it's arise a error. so i can use this code.
Vi(ky 8-May-14 4:23am    
Ensure your xml file is correct. Paste xml code here
http://www.w3schools.com/xml/xml_validator.asp
nitin.bhardwaj999 8-May-14 5:01am    
I have check my xml file is perfect.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900