Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点?_Xml_Vb.net_Reporting Services_Dataset_Ssrs 2008 - Fatal编程技术网

如何让ReadXml使用整个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中读取时爆炸第二

如何让ReadXml使用整个XML结构构建数据集,而不仅仅是第一个节点

我正在使用DataSet.ReadXml(MemoryStream)读取SSRSXML数据流的结果

将SSRS导出到XML错误“名为'Value'的列已属于DataTable:无法设置同名的嵌套表名

我得到这个错误是因为一些子节点有空的属性,而其他的基本上没有,第一个父节点的子节点具有所有空的子属性,第二个父节点的子节点确实具有这些属性的值。当ReadXml构建数据集时,它使用第一个父节点的结构,然后在sec中读取时爆炸第二个父母

我使用不同的日期范围调用相同的SSRS报告。对于较短的日期范围,当数据较少时,我会收到错误。对于较长的日期范围,问题不存在。XML的结构不会改变,除了以下节点外:

<TrendingChartGroup2 Label="Sep&#xA;&#xD;2013">
    <Value Y="0"/>

变成这样:

<TrendingChartGroup2 Label="Jun&#xA;&#xD;2013">
    <Value/>

ReadXml(MemoryStream)是否基于它看到的第一个XML节点构建数据集结构? 是否有一种方法可以在加载数据集之前读入XML结构,这样数据集就不会从它找到的前几个节点自动创建

下面是显示已知良好和已知不良XML节点和值的XML片段

已知货物:

<?xml version="1.0" encoding="utf-8"?>
<Report xsi:schemaLocation="MyReport2 http://reportserver?%2FMyReport2&amp;rs

%3AFormat=XML&amp;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&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Nov&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Dec&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jan&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Feb&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Mar&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Apr&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="May&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jun&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jul&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Aug&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Sep&#xA;&#xD;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&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Nov&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Dec&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jan&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Feb&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Mar&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Apr&#xA;&#xD;2013">
                    <Value Y="1"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="May&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jun&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jul&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Aug&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Sep&#xA;&#xD;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&amp;rs

%3AFormat=XML&amp;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&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Aug&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Sep&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Oct&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Nov&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Dec&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jan&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Feb&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Mar&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Apr&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="May&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jun&#xA;&#xD;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&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Aug&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Sep&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Oct&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Nov&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Dec&#xA;&#xD;2012">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jan&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Feb&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Mar&#xA;&#xD;2013">
                    <Value Y="0"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Apr&#xA;&#xD;2013">
                    <Value Y="1"/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="May&#xA;&#xD;2013">
                    <Value/>
                </TrendingChartGroup2>
                <TrendingChartGroup2 Label="Jun&#xA;&#xD;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、 这里有一些文章要回顾

然后,您的问题变成,如何对SSRS输出进行单元测试。此外,作为单元测试人员,您是想测试xml的SSRS结构还是结构中提供的值

测试结构

我将ssrsxml加载到visualstudio中,并使用xml菜单生成xml模式()显然,模式设计包含来自reports MDX查询的元数据,因此,如果要验证生成的xml结构是否正确,可能需要创建一些模板文档并替换一些元素名称,然后使用一些.net xml结构验证方法。请参阅


<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>