如何使用整個XML結構而不是第一個節點來獲取ReadXml來構建DataSet?如何使用整個XML結構而不僅僅是第一個節點來獲取ReadXml來構建DataSet?
我使用DataSet.ReadXml(MemoryStream)讀取SSRS XML蒸汽的結果。
出口SSRS到XML錯誤「命名的‘值’已經屬於數據表中的列:不能設置相同名稱的嵌套表名
我得到的錯誤監守一些子節點都空白atributes,和其他人基本上沒有,第一個Parent擁有所有空白子元素的子元素,第二個父元素有一些子元素具有這些屬性的值。當ReadXml構建數據集時,它使用第一個父元素的結構,然後在閱讀時炸彈在第二個父級中
我使用不同的日期範圍調用相同的SSRS報告使用較短的日期範圍,當數據較少並且出現錯誤時使用較長的da問題範圍不存在。的XML的結構不發生變化,除了諸如節點:
<TrendingChartGroup2 Label="Sep

2013">
<Value Y="0"/>
變爲這樣的:
<TrendingChartGroup2 Label="Jun

2013">
<Value/>
不DataSet.ReadXml(MemoryStream的)建立數據集結構基於斷第一XML節點它看到了嗎? 在加載數據集之前是否有讀取XML結構的方法,以便DataSet不是從它找到的前幾個節點創建的自動創建的?
下面是顯示已知良好和已知的不良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?
我懷疑SSRS XML數據的結構是分層的,而XML格式的普通數據集是扁平結構。通過閱讀數據試圖完成什麼?我假設你正在改變它的其他目的?爲什麼不直接跳過SSRS過程並直接查詢數據庫? –
我們正在對來自事務數據庫的「已知好」查詢進行SSRS報告輸出(xml)的自動測試。 SSRS報告針對立方體數據使用MDX查詢。我們將SSRS輸出與「已知好」查詢進行比較。 QA查詢和SSRS XML數據都會放入數據表中進行操作和比較。通常情況下,XML會很好,而不是隻有少量的數據。 :/ – BClaydon