如何从asp.net中的xml检索数据 [英] How to retrieve data from xml in asp.net

查看:72
本文介绍了如何从asp.net中的xml检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于上述内容,我想问一下ifi是否要搜索数据我可以得到它.当我输入带有某些字符"s"的子集的数据时,我必须获得带有子集s的标题,该子集是从xml文件中的数据中检索的.
[edit]已删除呼喊声-OriginalGriff [/edit]

With reference to the above i wanted to ask whether ifi want to search for data can i get it. when i type for data with subset with some character "s" i have to get title with subset s which is retrieved from the data in xml file

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

正在加载XML文件:

Loading a XML file:

XDocument doc = XDocument.Load(filename);



无论您要编写的Windows平台(WinForms,WPF,Silverlight,控制台或ASP.Net)如何,都可以通过这种方式进行.对于asp.net,您必须调用MapPath(具有所需的文件名),以便在服务器上获得实际路径,但这只是一个很小的变化.



You can do it this way regardless of the Windows platform (WinForms, WPF, Silverlight, Console, or ASP.Net) you''re coding for. For asp.net, you''ll have to call MapPath (with the desired filename) so that you get an actual path on the server, but that''s just a minor variation.


.NET中有几种不同的解析XML的方法.这是一个简短的概述:

There are several different ways to parse XML in .NET; here is a short overview:


  1. 使用System.Xml.XmlDocument类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
    请参见
  2. 使用类System.Xml.XmlTextReader; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ ].
  3. 使用类System.Xml.XmlTextReader;这是最快的读取方法,尤其是您需要跳过一些数据.
    请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].



—SA



—SA


这篇关于如何从asp.net中的xml检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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