This section talks about usage of several types residing in System.Xml namespaces that can be used to represent XML data.
X DO NOT use XmlNode or XmlDocument to represent XML data. Favor using instances of IXPathNavigable, XmlReader, XmlWriter, or subtypes of XNode instead.
XmlDocument are not designed for exposing in public APIs.
✓ DO use
IXPathNavigable, or subtypes of
XNode as input or output of members that accept or return XML.
Use these abstractions instead of
XmlNode, or XPathDocument, because this decouples the methods from specific implementations of an in-memory XML document and allows them to work with virtual XML data sources that expose
XmlReader, or XPathNavigator.
X DO NOT subclass
XmlDocument if you want to create a type representing an XML view of an underlying object model or data source.
Portions © 2005, 2009 Microsoft Corporation. All rights reserved.
Reprinted by permission of Pearson Education, Inc. from Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition by Krzysztof Cwalina and Brad Abrams, published Oct 22, 2008 by Addison-Wesley Professional as part of the Microsoft Windows Development Series.