Share via


WriteStartDocument (Compact 7)

3/12/2014

This method writes out the XML declaration with the version "1.0". The encoding attribute is determined by the IXmlWriterOutput implementation. By default, the encoding is UTF-8.

Syntax

HRESULT WriteStartDocument (
    XmlStandalone standalone
);

Parameters

  • standalone
    If XmlStandalone_Omit does not write a standalone attribute in the XML declaration, one of the following occurs:

    • If XmlStandalone_No, the writer writes standalone="no"
    • If XmlStandalone_Yes, the writer writes standalone="yes"

Return Value

This method returns S_OK if no error is generated.

Remarks

The following code shows WriteStartDocument:

if (FAILED(hr = pWriter->WriteStartDocument(XmlStandalone_Omit)))
{
    wprintf(L"Error, Method: WriteStartDocument, error is %08.8lx", hr);
    return -1;
}

Calling WriteStartDocument is the same as calling WriteProcessingInstruction passing a name of "xml" as an argument. Therefore, a program cannot successfully call both WriteStartDocument and WriteProcessingInstruction passing the name "xml" for the same document. It is valid to call WriteStartDocument and WriteProcessingInstruction for processing instructions that have a name other than the name "xml".

See Also

Reference

IXmlWriter Methods
IXmlWriterOutput
WriteProcessingInstruction
IXmlWriter Properties