开发者

linq to xml or xsd approach

There appears to be a fair amount of questions about linq to xml, and also about xsd. I want to know as a new C# developer, I need to utilize xml to provide settings for a feature that I am working on.

It seems that writing an XSD document and using xsd.exe to generate the C# code is a good way to go, because there's no need t开发者_JAVA百科o hand write the settings class, saving time, eliminating code, etc. However how should I compare this method with using Linq to XML? I am asking it seems that I'd have to write more code to query the xml and that's not such a good idea to me. What exactly is the benefit of using Linq to XML and in which situations can it be applied?

I get the feeling that Linq to XML is just another fancy way to work with XML.


Yes, Linq-to-XML is just another way to work with XML. It is somewhat simpler and more concise than the old System.Xml namespace.

If you're using XML to store settings, why not use the System.Configuration namespace? This is by far the simplest way to include settings in a .NET application. The ConfigurationManager class allows simply retrieval of configuration settings via a key/value pattern from an app.config / web.config file.

Check out http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜