System::Xml::XmlDocument::CreateXmlDeclaration method

XmlDocument::CreateXmlDeclaration method

Creates an XmlDeclaration node with the specified values.

virtual SharedPtr<XmlDeclaration> System::Xml::XmlDocument::CreateXmlDeclaration(const String &version, const String &encoding, const String &standalone)
ParameterTypeDescription
versionconst String&The version must be “1.0”.
encodingconst String&The value of the encoding attribute. This is the encoding that is used when you save the XmlDocument to a file or a stream; therefore, it must be set to a string supported by the Text::Encoding class, otherwise “XmlDocument::Save(String)” fails. If this is nullptr or String::Empty, the XmlDocument::Save method does not write an encoding attribute on the XML declaration and therefore the default encoding, UTF-8, is used.
standaloneconst String&The value must be either “yes” or “no”. If this is nullptr or String::Empty, the XmlDocument::Save method does not write a standalone attribute on the XML declaration.

ReturnValue

The new XmlDeclaration node.

Remarks

Note: If the XmlDocument is saved to either a TextWriter or an XmlTextWriter, this encoding value is discarded. Instead, the encoding of the TextWriter or the XmlTextWriter is used. This ensures that the XML written out can be read back using the correct encoding.

See Also