0 out of 3 rated this helpful - Rate this topic

XmlDataDocument Class

Note: This API is now obsolete.

Allows structured data to be stored, retrieved, and manipulated through a relational DataSet.

System.Object
  System.Xml.XmlNode
    System.Xml.XmlDocument
      System.Xml.XmlDataDocument

Namespace:  System.Xml
Assembly:  System.Data (in System.Data.dll)
[ObsoleteAttribute("XmlDataDocument class will be removed in a future release.")]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)]
public class XmlDataDocument : XmlDocument

The XmlDataDocument type exposes the following members.

  Name Description
Public method XmlDataDocument() Initializes a new instance of the XmlDataDocument class.
Public method XmlDataDocument(DataSet) Initializes a new instance of the XmlDataDocument class with the specified DataSet.
Top
  Name Description
Public property Attributes Gets an XmlAttributeCollection containing the attributes of this node. (Inherited from XmlNode.)
Public property BaseURI Gets the base URI of the current node. (Inherited from XmlDocument.)
Public property ChildNodes Gets all the child nodes of the node. (Inherited from XmlNode.)
Public property DataSet Gets a DataSet that provides a relational representation of the data in the XmlDataDocument.
Public property DocumentElement Gets the root XmlElement for the document. (Inherited from XmlDocument.)
Public property DocumentType Gets the node containing the DOCTYPE declaration. (Inherited from XmlDocument.)
Public property FirstChild Gets the first child of the node. (Inherited from XmlNode.)
Public property HasChildNodes Gets a value indicating whether this node has any child nodes. (Inherited from XmlNode.)
Public property Implementation Gets the XmlImplementation object for the current document. (Inherited from XmlDocument.)
Public property InnerText Gets the concatenated values of the node and all its child nodes. (Inherited from XmlDocument.)
Public property InnerXml Gets or sets the markup representing the children of the current node. (Inherited from XmlDocument.)
Public property IsReadOnly Gets a value indicating whether the current node is read-only. (Inherited from XmlDocument.)
Public property Item[String] Gets the first child element with the specified Name. (Inherited from XmlNode.)
Public property Item[String, String] Gets the first child element with the specified LocalName and NamespaceURI. (Inherited from XmlNode.)
Public property LastChild Gets the last child of the node. (Inherited from XmlNode.)
Public property LocalName Gets the local name of the node. (Inherited from XmlDocument.)
Public property Name Gets the qualified name of the node. (Inherited from XmlDocument.)
Public property NamespaceURI Gets the namespace URI of this node. (Inherited from XmlNode.)
Public property NameTable Gets the XmlNameTable associated with this implementation. (Inherited from XmlDocument.)
Public property NextSibling Gets the node immediately following this node. (Inherited from XmlNode.)
Public property NodeType Gets the type of the current node. (Inherited from XmlDocument.)
Public property OuterXml Gets the markup representing this node and all its child nodes. (Inherited from XmlNode.)
Public property OwnerDocument Gets the XmlDocument to which the current node belongs. (Inherited from XmlDocument.)
Public property ParentNode Gets the parent node of this node (for nodes that can have parents). (Inherited from XmlDocument.)
Public property Prefix Gets or sets the namespace prefix of this node. (Inherited from XmlNode.)
Public property PreserveWhitespace Gets or sets a value indicating whether to preserve white space in element content. (Inherited from XmlDocument.)
Public property PreviousSibling Gets the node immediately preceding this node. (Inherited from XmlNode.)
Public property SchemaInfo Returns the Post-Schema-Validation-Infoset (PSVI) of the node. (Inherited from XmlDocument.)
Public property Schemas Gets or sets the XmlSchemaSet object associated with this XmlDocument. (Inherited from XmlDocument.)
Public property Value Gets or sets the value of the node. (Inherited from XmlNode.)
Public property XmlResolver Sets the XmlResolver to use for resolving external resources. (Inherited from XmlDocument.)
Top
  Name Description
Public method AppendChild Adds the specified node to the end of the list of child nodes, of this node. (Inherited from XmlNode.)
Public method Clone Creates a duplicate of this node. (Inherited from XmlNode.)
Public method CloneNode Creates a duplicate of the current node. (Overrides XmlDocument.CloneNode(Boolean).)
Public method CreateAttribute(String) Creates an XmlAttribute with the specified Name. (Inherited from XmlDocument.)
Public method CreateAttribute(String, String) Creates an XmlAttribute with the specified qualified name and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateAttribute(String, String, String) Creates an XmlAttribute with the specified Prefix, LocalName, and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateCDataSection Creates an XmlCDataSection containing the specified data. (Inherited from XmlDocument.)
Public method CreateComment Creates an XmlComment containing the specified data. (Inherited from XmlDocument.)
Protected method CreateDefaultAttribute Creates a default attribute with the specified prefix, local name and namespace URI. (Inherited from XmlDocument.)
Public method CreateDocumentFragment Creates an XmlDocumentFragment. (Inherited from XmlDocument.)
Public method CreateDocumentType Returns a new XmlDocumentType object. (Inherited from XmlDocument.)
Public method CreateElement(String) Creates an element with the specified name. (Inherited from XmlDocument.)
Public method CreateElement(String, String) Creates an XmlElement with the qualified name and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateElement(String, String, String) Creates an element with the specified Prefix, LocalName, and NamespaceURI. (Overrides XmlDocument.CreateElement(String, String, String).)
Public method CreateEntityReference Creates an XmlEntityReference with the specified name. XmlEntityReference nodes cannot be created for XmlDataDocument objects. Calling this method throws an exception. (Overrides XmlDocument.CreateEntityReference(String).)
Public method CreateNavigator() Creates a new XPathNavigator object for navigating this document. (Inherited from XmlDocument.)
Protected method CreateNavigator(XmlNode) Creates a new XPathNavigator object for navigating this document. The XPathNavigator is positioned on the node specified in the node parameter. (Overrides XmlDocument.CreateNavigator(XmlNode).)
Public method CreateNode(String, String, String) Creates an XmlNode with the specified node type, Name, and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateNode(XmlNodeType, String, String) Creates an XmlNode with the specified XmlNodeType, Name, and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateNode(XmlNodeType, String, String, String) Creates a XmlNode with the specified XmlNodeType, Prefix, Name, and NamespaceURI. (Inherited from XmlDocument.)
Public method CreateProcessingInstruction Creates an XmlProcessingInstruction with the specified name and data. (Inherited from XmlDocument.)
Public method CreateSignificantWhitespace Creates an XmlSignificantWhitespace node. (Inherited from XmlDocument.)
Public method CreateTextNode Creates an XmlText with the specified text. (Inherited from XmlDocument.)
Public method CreateWhitespace Creates an XmlWhitespace node. (Inherited from XmlDocument.)
Public method CreateXmlDeclaration Creates an XmlDeclaration node with the specified values. (Inherited from XmlDocument.)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetElementById Gets the XmlElement with the specified ID. This method is not supported by the XmlDataDocument class. Calling this method throws an exception. (Overrides XmlDocument.GetElementById(String).)
Public method GetElementFromRow Retrieves the XmlElement associated with the specified DataRow.
Public method GetElementsByTagName(String) Returns an XmlNodeList containing a list of all descendant elements that match the specified Name. (Overrides XmlDocument.GetElementsByTagName(String).)
Public method GetElementsByTagName(String, String) Returns an XmlNodeList containing a list of all descendant elements that match the specified LocalName and NamespaceURI. (Inherited from XmlDocument.)
Public method GetEnumerator Provides support for the for each style iteration over the nodes in the XmlNode. (Inherited from XmlNode.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetNamespaceOfPrefix Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration. (Inherited from XmlNode.)
Public method GetPrefixOfNamespace Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration. (Inherited from XmlNode.)
Public method GetRowFromElement Retrieves the DataRow associated with the specified XmlElement.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ImportNode Imports a node from another document to the current document. (Inherited from XmlDocument.)
Public method InsertAfter Inserts the specified node immediately after the specified reference node. (Inherited from XmlNode.)
Public method InsertBefore Inserts the specified node immediately before the specified reference node. (Inherited from XmlNode.)
Public method Load(Stream) Loads the XmlDataDocument from the specified stream. (Overrides XmlDocument.Load(Stream).)
Public method Load(String) Loads the XmlDataDocument using the specified URL. (Overrides XmlDocument.Load(String).)
Public method Load(TextReader) Loads the XmlDataDocument from the specified TextReader. (Overrides XmlDocument.Load(TextReader).)
Public method Load(XmlReader) Loads the XmlDataDocument from the specified XmlReader. (Overrides XmlDocument.Load(XmlReader).)
Public method LoadXml Loads the XML document from the specified string. (Inherited from XmlDocument.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Normalize Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes. (Inherited from XmlNode.)
Public method PrependChild Adds the specified node to the beginning of the list of child nodes for this node. (Inherited from XmlNode.)
Public method ReadNode Creates an XmlNode object based on the information in the XmlReader. The reader must be positioned on a node or attribute. (Inherited from XmlDocument.)
Public method RemoveAll Removes all the child nodes and/or attributes of the current node. (Inherited from XmlNode.)
Public method RemoveChild Removes specified child node. (Inherited from XmlNode.)
Public method ReplaceChild Replaces the child node oldChild with newChild node. (Inherited from XmlNode.)
Public method Save(Stream) Saves the XML document to the specified stream. (Inherited from XmlDocument.)
Public method Save(String) Saves the XML document to the specified file. (Inherited from XmlDocument.)
Public method Save(TextWriter) Saves the XML document to the specified TextWriter. (Inherited from XmlDocument.)
Public method Save(XmlWriter) Saves the XML document to the specified XmlWriter. (Inherited from XmlDocument.)
Public method SelectNodes(String) Selects a list of nodes matching the XPath expression. (Inherited from XmlNode.)
Public method SelectNodes(String, XmlNamespaceManager) Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager. (Inherited from XmlNode.)
Public method SelectSingleNode(String) Selects the first XmlNode that matches the XPath expression. (Inherited from XmlNode.)
Public method SelectSingleNode(String, XmlNamespaceManager) Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager. (Inherited from XmlNode.)
Public method Supports Test if the DOM implementation implements a specific feature. (Inherited from XmlNode.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Validate(ValidationEventHandler) Validates the XmlDocument against the XML Schema Definition Language (XSD) schemas contained in the Schemas property. (Inherited from XmlDocument.)
Public method Validate(ValidationEventHandler, XmlNode) Validates the XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the Schemas property. (Inherited from XmlDocument.)
Public method WriteContentTo Saves all the children of the XmlDocument node to the specified XmlWriter. (Inherited from XmlDocument.)
Public method WriteTo Saves the XmlDocument node to the specified XmlWriter. (Inherited from XmlDocument.)
Top
  Name Description
Public event NodeChanged Occurs when the Value of a node belonging to this document has been changed. (Inherited from XmlDocument.)
Public event NodeChanging Occurs when the Value of a node belonging to this document is about to be changed. (Inherited from XmlDocument.)
Public event NodeInserted Occurs when a node belonging to this document has been inserted into another node. (Inherited from XmlDocument.)
Public event NodeInserting Occurs when a node belonging to this document is about to be inserted into another node. (Inherited from XmlDocument.)
Public event NodeRemoved Occurs when a node belonging to this document has been removed from its parent. (Inherited from XmlDocument.)
Public event NodeRemoving Occurs when a node belonging to this document is about to be removed from the document. (Inherited from XmlDocument.)
Top
  Name Description
Explicit interface implemetation Private method ICloneable.Clone For a description of this member, see XmlNode.Clone. (Inherited from XmlNode.)
Explicit interface implemetation Private method IEnumerable.GetEnumerator For a description of this member, see XmlNode.GetEnumerator. (Inherited from XmlNode.)
Top

This class extends XmlDocument. It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because XmlDataDocument implements the IXPathNavigable interface, it can also be used as the source document for the XslTransform class.

XmlDataDocument has a close affiliation with the DataSet class, which provides a relational view of the loaded XML data. Any changes made to the XmlDataDocument are reflected in the DataSet and vice versa.

To load a DataSet with XML data, use ReadXmlSchema to build a relational mapping. The XML data can then be loaded using Load or LoadXml.

To load relational data, specify the DataSet containing the relational data as the parameter in the XmlDataDocument constructor.

Note Note

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Obsolete (compiler warning) in 4

.NET Framework Client Profile

Supported in: 3.5 SP1
Obsolete (compiler warning) in 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
What to use instead?
Any word on what we should use instead now it's obsolete?

I would recommend using XDocument (http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx).
what to use for replacement
I see the replacement is WriteXml, but the problem I have is that WriteXml just creates the file and places it in a specified location. In my app I was using XmlDataDocument to create the file and then give the user the save Dialog box so that they could open the file or save it to a location of their choosing. here is the code I was using.

Dim xmlDoc As System.Xml.XmlDataDocument
Dim xmlDec As System.Xml.XmlDeclaration
Dim xmlWriter As System.Xml.XmlWriter
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment; filename=" + filename + ".xml")
Response.ContentType = "application/vnd.xml"
Response.Charset = "utf-8"
xmlWriter = New System.Xml.XmlTextWriter(Me.Response.OutputStream, System.Text.Encoding.UTF8)
xmlDoc = New System.Xml.XmlDataDocument(ds)
xmlDoc.DataSet.EnforceConstraints = False
xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)
xmlDoc.PrependChild(xmlDec)
xmlDoc.WriteTo(xmlWriter)
xmlWriter.Flush()
xmlWriter.Close()

How do I use ds.WriteXml to have that same functionality
Need replacement
It looks like the replacement would be the

WriteXml method of DATASET

Dim CryptoData As System.Data.DataSet = New System.Data.DataSet

Dim sCommand As String = "SELECT [USER_ID], [PUBLIC_KEY] FROM [CVS_OfficeDB].[dbo].[CVS_OFFICE_KEYS] "
Console.WriteLine("Creating an Adapter to load the DataSet.")
tmpDataAdapter = New System.Data.SqlClient.SqlDataAdapter(sCommand, tmpSqlConnection)
'Fill the DataSet with the selected records.
tmpDataAdapter.Fill(CryptoData, "CVS_OFFICE_KEYS")
CryptoData.WriteXml("C:\Documents and Settings\wymand\My Documents\Visual Studio 2010\Projects\Crypto_to_XML\CVS_Crypto_Users.XML", XmlWriteMode.IgnoreSchema)