如何通过使用数据库中的数据创建自定义XML文件 [英] Ho TO Create Custom XML File By Using data from Database

查看:79
本文介绍了如何通过使用数据库中的数据创建自定义XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我想通过使用数据集字段以自定义格式创建XML文件.意味着我具有从DataDase&中检索到的数据集中的值.我想创建自定义XML文件.
我想要这种格式的MXL文件,例如:

-------------------------------------------------- ----------------------------------
< pddata>
< id>
< cid> -无需填写,在Yos内部(将在卡上打印的卡ID)< pid> 199909150022
-患者ID-必填(UHID)
< yid>
-无需填写,在Yos内部(将以字母打印的YosCare ID)
< pwd>
-无需填写,在Yos内部(YosCare密码将为字母)

Hello Friends,

I want to create XML File in custom format by using dataset fields.means i have the values in dataset which i retrieve from DataDase & i want to create Custom XML file.
i want MXL File in This Formate like :

------------------------------------------------------------------------------------
<pddata>
<id>
<cid> - Need Not be filled, Internal to Yos(Card ID that will be printed on card) <pid>199909150022
- Patient Id - Mandatory (UHID)
<yid>
- Need Not be filled, Internal to Yos(YosCare ID that will be printed in letter)
<pwd>
- Need Not be filled, Internal to Yos(YosCare password that will be letter)

推荐答案

Google DataSet.WriteXml()


我不知道所有的"Yos"内容,但是通常你会

1.创建一个由类组成的数据模型,这些类保存数据库中的数据.
2.将这些类的实例序列化到磁盘.
由于需要XML,因此可以使用 XMLSerializer [ ^ ]或 SoapFormatter [ ^ ].这两个的工作方式非常不同,但是都创建了某种XML输出.
I don''t know all the "Yos" stuff, but generally you would

1. Create a data model made of classes that hold the data from database.
2. Serialize instances of those classes to disk.
Since you want XML, you could use XMLSerializer[^] or SoapFormatter[^]. These two work very differently, but both create some kind of XML output.


我支持lukeer解释的方法,但是我没有提到序列化方法.通过使用数据合同,您可以做得更好,更轻松.

请参阅 http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

我解释了为什么在过去的解决方案中如此好:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
I support the approach explained by lukeer, but I don''t the serialization methods mentioned. You could do much better an easier by using Data Contract.

See http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

I explained why it''s so good in my past solutions:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

—SA


这篇关于如何通过使用数据库中的数据创建自定义XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆