如何在C#中使用Sql查询创建Xml [英] How To I Create Xml Using Sql Query In C#
问题描述
我在sql中有我的数据,我想用C#创建XML,我的输出应该是:
< pre lang =xml> < 声明 >
< ID > ; SGHADM018933 < / ID >
< ReceiverID > ; TPA009 < / ReceiverID >
< PayerID > ; INS083 < / PayerID >
< FacilityID > DHA-F-0046775 < / FacilityID >
< 列表 > 4398.7 < / List >
< Gross > 3503.9 < / Gross >
< Deductible > 0.0 < / Deductible >
< PatientShare > 0.0 < / PatientShare >
< Net > 3503.9 < / Net >
< ClientBatchID > CLAIM0000009449 < / ClientBatchID >
<! - 遇到相关信息 - >
< 遭遇 >
< 类型 > 住院病床+急诊室< /类型 >
< PatientID > 00042077 < / PatientID >
< 开始 > 02/05/2015 21:52 < / Start >
< 结束 > 03/05/2015 21:52 < / End >
< StartType < span class =code-keyword>> 紧急< / StartType >
< EndType < span class =code-keyword>> 已批准< / EndType >
< TransferSource > DHA-F-0000792 < / TransferSource >
< TransferDestination > < / TransferDestination >
< / Encounter >
< / Claim >
急需帮助
-更新
如果我的问题不明确,我很抱歉。我是C#的新手,想要使用查询创建XML。我试过这段代码:
string strSQL = select * from accumedip;
SqlDataAdapter dt = new SqlDataAdapter(strSQL,con);
DataSet ds = new DataSet();
dt.Fill(ds, accumedip);
ds.WriteXml(Server.MapPath( IP_xml_file.xml));
LabelMessage.Text = XML文件;
但输出不是我想要的
请阅读我对这个问题的评论。
根据我的理解,您正在尝试从accumedip
表创建xml文件,该表存储声明
数据。但是你需要添加遇到
数据,这可能 - 存储在另一个表中。
看看这里:嵌套数据关系 [ ^ ]
Hi,
I have my data in sql, i want to create XML using C# ,my output should be:
<Claim>
<ID>SGHADM018933</ID>
<ReceiverID>TPA009</ReceiverID>
<PayerID>INS083</PayerID>
<FacilityID>DHA-F-0046775</FacilityID>
<List>4398.7</List>
<Gross>3503.9</Gross>
<Deductible>0.0</Deductible>
<PatientShare>0.0</PatientShare>
<Net>3503.9</Net>
<ClientBatchID>CLAIM0000009449</ClientBatchID>
<!--Encounter information-->
<Encounter>
<Type>Inpatient Bed + Emergency Room</Type>
<PatientID>00042077</PatientID>
<Start>02/05/2015 21:52</Start>
<End>03/05/2015 21:52</End>
<StartType>Emergency</StartType>
<EndType>Discharged with Approval</EndType>
<TransferSource>DHA-F-0000792</TransferSource>
<TransferDestination></TransferDestination>
</Encounter>
</Claim>
Need urgent help
-Update
i'm sorry if my question is not clear. I'm new to C# and want to create XML using a query. I tried this code :
string strSQL = "Select * from accumedip";
SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet();
dt.Fill(ds, "accumedip");
ds.WriteXml(Server.MapPath("IP_xml_file.xml"));
LabelMessage.Text = " XML file";
but the output is not how i want it to be
Please, read my comment to the question.
As per my understanding, you're trying to create xml file fromaccumedip
table, which storesclaim
data. But you need to addencounter
data, which - probably - is stored in another table.
Have a look here: Nesting DataRelations[^]
这篇关于如何在C#中使用Sql查询创建Xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!