Creates an System.Xml.XmlDeclaration node with the specified values.
- version
- The version must be "1.0".
- encoding
- The value of the encoding attribute. This is the encoding that is used when you save the System.Xml.XmlDocument to a file or a stream; therefore, it must be set to a string supported by the System.Text.Encoding class, otherwise XmlDocument.Save(string) fails. If this is null or String.Empty, the Save method does not write an encoding attribute on the XML declaration and therefore the default encoding, UTF-8, is used.
- standalone
- The value must be either "yes" or "no". If this is null or String.Empty, the Save method does not write a standalone attribute on the XML declaration.
The new XmlDeclaration node.
The attributes are exposed as special properties on the XmlDeclaration node, and not as System.Xml.XmlAttribute nodes.
Although this method creates the new object in the context of the document, it does not automatically add the new object to the document tree. To add the new object, you must explicitly call one of the node insert methods.
According to the W3C Extensible Markup Language (XML) 1.0 recommendation (www.w3.org/TR/1998/REC-xml-19980210), the XmlDeclaration node must be the first node in the document.
This method is a Microsoft extension to the Document Object Model (DOM).