无法添加嵌套关系或元素列包含简单文本列的表 [英] Cannot add a nested relation or an element column to a table containing a SimpleContent column

查看:423
本文介绍了无法添加嵌套关系或元素列包含简单文本列的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜IAM写这篇code

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(); "

和此错误happing

and this error is happing

不能添加嵌套关系或元素列包含简单文本列的表

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

推荐答案

您的问题是您在文档中使用不同的结构具有相同的元素名的地方。

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>

和后来在文档中有

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

由于它是基于早期的声明中已经定义的项目为简单文本列中的XSD将无法生成第二项属性结构的正确模式。

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.

解决方案是(自然)避免使用相同的元素名称为您的XML中的不同结构。显然,你的情况是有点不方便,因为微软拥有有问题的XML(只是假设,因为从杰尼评论表示该网站已不复存在。)你不得不使用XMLWriter的或某些变种换出违规元素的名称独特的东西。

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.

这篇关于无法添加嵌套关系或元素列包含简单文本列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆