如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点?
如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点 我正在使用DataSet.ReadXml(MemoryStream)读取SSRSXML数据流的结果 将SSRS导出到XML错误“名为'Value'的列已属于DataTable:无法设置同名的嵌套表名 我得到这个错误是因为一些子节点有空的属性,而其他的基本上没有,第一个父节点的子节点具有所有空的子属性,第二个父节点的子节点确实具有这些属性的值。当ReadXml构建数据集时,它使用第一个父节点的结构,然后在sec中读取时爆炸第二个父母 我使用不同的日期范围调用相同的SSRS报告。对于较短的日期范围,当数据较少时,我会收到错误。对于较长的日期范围,问题不存在。XML的结构不会改变,除了以下节点外:如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点?,xml,vb.net,reporting-services,dataset,ssrs-2008,Xml,Vb.net,Reporting Services,Dataset,Ssrs 2008,如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点 我正在使用DataSet.ReadXml(MemoryStream)读取SSRSXML数据流的结果 将SSRS导出到XML错误“名为'Value'的列已属于DataTable:无法设置同名的嵌套表名 我得到这个错误是因为一些子节点有空的属性,而其他的基本上没有,第一个父节点的子节点具有所有空的子属性,第二个父节点的子节点确实具有这些属性的值。当ReadXml构建数据集时,它使用第一个父节点的结构,然后在sec中读取时爆炸第二
<TrendingChartGroup2 Label="Sep

2013">
<Value Y="0"/>
变成这样:
<TrendingChartGroup2 Label="Jun

2013">
<Value/>
ReadXml(MemoryStream)是否基于它看到的第一个XML节点构建数据集结构?
是否有一种方法可以在加载数据集之前读入XML结构,这样数据集就不会从它找到的前几个节点自动创建
下面是显示已知良好和已知不良XML节点和值的XML片段
已知货物:
<?xml version="1.0" encoding="utf-8"?>
<Report xsi:schemaLocation="MyReport2 http://reportserver?%2FMyReport2&rs
%3AFormat=XML&rc%3ASchema=True" Name="MyReport2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="MyReport2">
<Rehosp30DaysCurrDxChart1>
<Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_DxGroupName Label="Episode Of Care
As Treatment DxGroupName">
<TrendingChartGroup2_Collection>
<TrendingChartGroup2 Label="Oct

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Nov

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Dec

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jan

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Feb

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Mar

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Apr

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="May

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jun

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jul

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Aug

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Sep

2013">
<Value Y="0"/>
</TrendingChartGroup2>
</TrendingChartGroup2_Collection>
</Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_DxGroupName>
<Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_Pneumonia Label="Episode Of
Care As Treatment Pneumonia">
<TrendingChartGroup2_Collection>
<TrendingChartGroup2 Label="Oct

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Nov

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Dec

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jan

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Feb

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Mar

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Apr

2013">
<Value Y="1"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="May

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jun

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jul

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Aug

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Sep

2013">
<Value Y="0"/>
</TrendingChartGroup2>
</TrendingChartGroup2_Collection>
</Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_Pneumonia>
</Rehosp30DaysCurrDxChart1>
</Report>
已知不良:
<?xml version="1.0" encoding="utf-8"?>
<Report xsi:schemaLocation="MyReport2 http://reportserver?%2FMyReport2&rs
%3AFormat=XML&rc%3ASchema=True" Name="MyReport2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="MyReport2">
<Rehosp30DaysCurrDxChart1>
<Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_DxGroupName Label="Episode Of Care
As Treatment DxGroupName">
<TrendingChartGroup2_Collection>
<TrendingChartGroup2 Label="Jul

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Aug

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Sep

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Oct

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Nov

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Dec

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jan

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Feb

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Mar

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Apr

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="May

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jun

2013">
<Value/>
</TrendingChartGroup2>
</TrendingChartGroup2_Collection>
</Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_DxGroupName>
<Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_Pneumonia Label="Episode Of
Care As Treatment Pneumonia">
<TrendingChartGroup2_Collection>
<TrendingChartGroup2 Label="Jul

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Aug

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Sep

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Oct

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Nov

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Dec

2012">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jan

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Feb

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Mar

2013">
<Value Y="0"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Apr

2013">
<Value Y="1"/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="May

2013">
<Value/>
</TrendingChartGroup2>
<TrendingChartGroup2 Label="Jun

2013">
<Value Y="0"/>
</TrendingChartGroup2>
</TrendingChartGroup2_Collection>
</Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_Pneumonia>
</Rehosp30DaysCurrDxChart1>
</Report>
我不明白DataSet.ReadXml(MemoryStream)是如何构建数据集的
谢谢
编辑:我应该在数据集中添加我需要的数据,因为现有代码到处都使用数据集。有没有办法将XDocument添加到数据集来解决此问题?在这种情况下,我根本不会使用dataset.Readxml。重新考虑读取xml的方法可能是一个好主意。.NET提供了许多方法来完成此操作s、 这里有一些文章要回顾
<xs:element name="Rehosp30DaysCurrDxChart1">
<xs:complexType>
<xs:sequence>
<xs:element name="Episode_x0020_Of_x0020_Care_x0020_From_x0020_Hospital_x0020_DxGroupName">
<xs:complexType>
<xs:sequence>
<xs:element name="TrendingChartGroup2_Collection">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="TrendingChartGroup2">
<xs:complexType>
<xs:sequence>
<xs:element name="Value" />
</xs:sequence>
<xs:attribute name="Label" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Label" type="xs:string" use="required" />
</xs:complexType>
</xs:element>