使用C#搜索XML文件 [英] Search on XML file using C#
本文介绍了使用C#搜索XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何在xml文件上搜索节点或元素?任何帮助
我尝试了什么:
i我是新手所以我没有尝试任何东西
i don't know how to searching on nodes or elements on xml file ? any help
What I have tried:
i am a newbie so i didn't try anything
推荐答案
引用:
我是新手所以我没有尝试任何东西
i am a newbie so i didn't try anything
要做的第一件事,搜索互联网,使用谷歌或StackOverfow。
你将不得不使用一个库来处理XML文件,程序将依赖于库。选择带有tutos的库。
First thing to do, search internet, use either Google or StackOverfow.
You will have to use a library to handle the XML file, the procedure will depend on library. Choose a library with tutos.
.NET FCL提供了使用XML的不同方法。您可以使用类System.Xml.Linq.XDocument
;这是类似于XmlDocument
的最合适的方式,支持LINQ to XML Programming。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx ,http://msdn.microsoft.com/en-us/library/bb387063.aspx 。
但你的问题可能更严重。首先,作为一个新手并不是不阅读文档的借口,特别是原始的MSDN文档。
另外,你应该首先思考:你真的需要搜索节点?也许您需要序列化,而不是搜索节点,而是搜索基础数据模型的内存中表示中的某些数据?答案取决于你的最终目标。所以,当你提出问题时,解释你的最终目标总是一个好主意。也许你认为需要的不是你真正需要的。
-SA
.NET FCL offers different ways of working with XML. You can use the classSystem.Xml.Linq.XDocument
; this is the most adequate way similar to that ofXmlDocument
, 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.
But your problems are probably more serious. First, being a "newbie" is not an excuse for not reading the documentation, especially original MSDN documentation.
Also, you should think first: do you really need to search for nodes? Maybe you need the serialization, and search not for nodes, but for certain data in the in-memory representation of your base data model? The answer depends on your ultimate goals. So, when you ask a question, it's always a good idea to explain your ultimate goal. Maybe what you think is need is not what you really need.
—SA
这篇关于使用C#搜索XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文