I am now learning XmlDocument
but I've just ran into XDocument
and when I try to search the difference or benefits of them I can't find something useful, could you please tell me why you would use one over another ?
相关问题
- Sorting 3 numbers without branching [closed]
- Illegal to have multiple roots (start tag in epilo
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
XmlDocument
is great for developers who are familiar with the XML DOM object model. It's been around for a while, and more or less corresponds to a W3C standard. It supports manual navigation as well asXPath
node selection.XDocument
powers the LINQ to XML feature in .NET 3.5. It makes heavy use ofIEnumerable<>
and can be easier to work with in straight C#.Both document models require you to load the entire document into memory (unlike
XmlReader
for example).Also, note that
XDocument
is supported in Xbox 360 and Windows Phone OS 7.0. If you target them, develop forXDocument
or migrate fromXmlDocument
.