使用C#(asp.net)在存在的xml数据库上执行查询 [英] execute queries on xml database in exist with c#(asp.net)

查看:68
本文介绍了使用C#(asp.net)在存在的xml数据库上执行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是XML新手,在xml db上执行查询时遇到一些问题.我正在使用现有的本地xml数据库.您可以编写示例插入,更新,删除查询以及如何执行查询.
这是我的示例xml文件:

 <  用户 > ; 
    <  用户 > 
        <  全名 > 
弗雷德里克
<  /fullname  > 
        <  用户名 > 
弗雷德
<  /username  > 
        <  密码 > 
123
<  /password  > 
    <  /user  > 
<  /users  >                                                pre> 

在此先谢谢您

解决方案

您可以使用Xml.Linq进行查询.

 使用 使用
//  ... 
//  ... 
//  ... 
私有 无效 QueryFromXml(字符串 xmlFilePath)
{
XDocument xmlDoc = XDocument.Load(xmlFilePath);
 var  myNode =(来自的来自 xmlDoc中.Descendants(" )
             选择 p.Element("  ).价值);
//  .... 
// 在此处放置代码以完成您要对查询执行的操作.
//  .... 


} 


检查此博客
http://msdn.microsoft.com/en-us/library/bb397906.aspx [ ^ ]
--NDK


Hi all,

I am new in XML and have some problems to execute queries on xml db. I am using exist native xml db. Can you write sample insert, update,delete queries and how to execute them.
this is my sample xml file:

<users>
    <user>
        <fullname>
		Frederick
	</fullname>
        <username>
		Fred
	</username>
        <password>
		123
	</password>
    </user>
</users>



Thanks in advance

解决方案

You can use Xml.Linq for your query.

using using System.Xml.Linq;
//...
//...
//...
private void QueryFromXml(string xmlFilePath)
{
XDocument xmlDoc = XDocument.Load(xmlFilePath);
var myNode= (from p in xmlDoc.Descendants("user")
             select p.Element("fullname").Value);
//....
// Place code here to do whatever you want to do with the query.
//....


}


check this blog
http://msdn.microsoft.com/en-us/library/bb397906.aspx[^]
--NDK


这篇关于使用C#(asp.net)在存在的xml数据库上执行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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