Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add a nested relation or an element column to a table containing a SimpleContent column

Hi iam write this code

"

 XmlTextReader read = new XmlTextReader("http://msdn.microsoft.com/rss.xml");
        DataSet ds = new DataSet();
        ds.ReadXml(read);
        ListView1.DataSource = ds.Tables[4];
        ListView1.DataBind(); "

and this error is happing

"Cannot add a nested relation or an element column to a table containing a SimpleContent column"

like image 818
Darsh Avatar asked Sep 23 '11 14:09

Darsh


1 Answers

Your problem is you have the same element name with a different structure somewhere in the document.

So, for example, if you have

<Item>Bicycle</Item>

and later in the document you have

<Item Type="Sports"><Name>Bicycle</Name></Item>

The XSD will fail to generate a proper schema for the second Item attribute structure because it's already defined Item as a SimpleContent column based on the earlier declaration.

The solution is to (naturally) avoid using the same element name for different structures within your XML. Obviously in your case that's kind of inconvenient since Microsoft owns the XML in question (hypothetically, since the comment from Deni indicates this site no longer exists.) You'd have to use XMLWriter or some variant to swap out the name of the offending element for something unique.

like image 182
Kyle Hale Avatar answered Nov 14 '22 23:11

Kyle Hale