从xml文件中选择* [英] select * from xml file

查看:96
本文介绍了从xml文件中选择*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xml文件


从表名中选择*;就像我从xml文件中选择所有节点一样

i have an xml file


select * from tablename; same like i cal select all nodes from xml file

推荐答案

Shanya有多种方法.

您可以使用XmlDocument,如下所示加载xml文件
There are various ways Shanya.

One you can use XmlDocument, load the xml file as shown below
XmlDocument xDoc = new XmlDocument();
xDoc.Load("yourxml.xml");

XmlNodeList nodes = xDoc.DocumentElement.SelectNodes("NodeName");



请注意,在上面的代码中,"NodeName实际上是Xpath.您可以像Node/ChildNode/GrandChildNode这样给它命名,等等.您可以在 ^ ]

另一种方法是直接使用LinQ并按照您的建议使用选择查询,如 http://stackoverflow.com/questions/670563/linq-to-read-xml [ ^ ]

您所提供的信息有限,将无法提供确切的解决方案.


希望对您有帮助

Milind



Note, that in above code, "NodeName is actually Xpath. You can give it like Node/ChildNode/GrandChildNode and so on. You can find more details about xPath at www.w3schools.com/xpath/default.asp[^]

Other way is to directly use LinQ and use select query as you are suggesting as shown very simply at http://stackoverflow.com/questions/670563/linq-to-read-xml[^]

With limited information you have given, won''t be able to give exact solution.


Hope that helps

Milind


这篇关于从xml文件中选择*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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