阅读Xml InnerText节点 [英] Read Xml InnerTExt Node
本文介绍了阅读Xml InnerText节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为sysparam.xml的xml文件包含:
I have an xml file named "sysparam.xml" contain:
<Name>Jack</Name>
<LastName>Jerald</LastName>
i想要一个vb.net中的类,它将节点的内部文本作为字符串返回,其方法应如下所示:
i want a class in vb.net that return the inner text of the node as a string where the method should look like :
Function GetParamValue(ByVal oKey As String) As String
.
.
.
.
end function
任何帮助请
Any Help Please
推荐答案
因为.NET FCL提供了解析和生成XML的不同方法,所以你有去挑选最适合你的东西。这是我的简短概述:
As .NET FCL provides different ways for parsing and generating XML, you have to pick up what will suit you the most. This is my short overview:
- 使用
System.Xml.XmlDocument
class。它实现了DOM接口;如果文档的大小不是太大,这种方式是最简单和最好的。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [ ^ ]。 - 使用类
System.Xml.XmlTextWriter
和System.Xml.XmlTextReader
;这是最快的阅读方式,特别是你需要跳过一些数据。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx [ ^ ], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ ^ ]。 - 使用类
系统.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 [ ^ ]。
- 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[^]. - Use the classes
System.Xml.XmlTextWriter
andSystem.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.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.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[^].
祝你好运,
这篇关于阅读Xml InnerText节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文