如何在c#.NET中将sql表XML列数据处理成集合? [英] How to process sql table XML column data into collection in c#.NET?

查看:184
本文介绍了如何在c#.NET中将sql表XML列数据处理成集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的sql表中,一列有XML列,以xml格式保存数据。



我想将sql table xml列数据提取到c#代码中,将其存储到字符串变量中。一旦我将它存储到字符串变量中,我想将所有xml属性键和值存储到Collection中。



注意 - >

XML以下格式提供的列数据

 <   customer  >  
< pri_one > 1 < / pri_one >
< cust_name > < / cust_name >
< /客户 >



如何在c#.net中实现它?



请建议任何一种方法!

解决方案

< blockquote>你可以使用XML解析器或LINQ



XML解析...

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(yourXMLFile.xml);


Hi,

In my sql table one of column having XML column which hold data in xml format.

I want to fetch that sql table xml column data into c# code, stored it into string variable. once i store it into string variable i want to store all xml attribute key and value into Collection.

Note-->
XML column data available in below format

<customer>
 <pri_one>1</pri_one> 
<cust_name>A</cust_name>
</customer>


How i achieve it in c#.net?

Please suggest any one approach!

解决方案

You can use the XML parser or LINQ

XML Parsing...
XmlDocument xmlDoc= new XmlDocument();
xmlDoc.Load("yourXMLFile.xml");


这篇关于如何在c#.NET中将sql表XML列数据处理成集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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