1
我正在構建一個web服務,它有一個webmethod返回一個Dataset對象。強制XML標記在序列化數據集時出現
我遇到問題當其關聯值爲空時,不會寫入XML標記。
一個簡單的例子是如下:
ID Name Text
-- ------ -------------
1 NULL test1 <------- null value
2 toto test2
3 tata test3
獲取XML序列化到:
<table roworder="1">
<id> 1 </id> <----- element missing when value = null
<text> test1 </text>
</table>
<table roworder="2">
<id> 2 </id>
<name> toto </name>
<text> test2 </text>
</table>
<table roworder="3">
<id> 3 </id>
<name> tata </name>
<text> test3 </text>
</table>
這是給我的問題,當我在Reporting Services掛鉤這個XML起來。如果第一行的元素爲空,則不會將其識別爲報告字段,並且結果中沒有整列。
有沒有辦法強制XML序列化,如果其相關聯的值爲空,將放入空元素?
EX:
<table roworder="1">
<id> 1 </id>
<name> </name> <---- empty element for null value
<text> test1 </text>
</table>
感謝
Chetan:這不是一個選項,因爲我們返回的數據集來自一些奇怪的OLEDB連接,並且我們對它對數據庫的查詢沒有實際影響。 – scoob 2009-01-29 20:52:28