XmlWriter.WriteStartDocument Método

Definição

Quando substituído em uma classe derivada, grava a declaração XML.When overridden in a derived class, writes the XML declaration.

Sobrecargas

WriteStartDocument(Boolean)

Quando substituído em uma classe derivada, grava a declaração XML com a versão "1.0" e o atributo autônomo.When overridden in a derived class, writes the XML declaration with the version "1.0" and the standalone attribute.

WriteStartDocument()

Quando substituído em uma classe derivada, grava a declaração XML com a versão "1.0".When overridden in a derived class, writes the XML declaration with the version "1.0".

Comentários

Para obter a versão assíncrona desse método, consulte WriteStartDocumentAsync .For the asynchronous version of this method, see WriteStartDocumentAsync.

WriteStartDocument(Boolean)

Quando substituído em uma classe derivada, grava a declaração XML com a versão "1.0" e o atributo autônomo.When overridden in a derived class, writes the XML declaration with the version "1.0" and the standalone attribute.

public:
 abstract void WriteStartDocument(bool standalone);
public abstract void WriteStartDocument (bool standalone);
abstract member WriteStartDocument : bool -> unit
Public MustOverride Sub WriteStartDocument (standalone As Boolean)

Parâmetros

standalone
Boolean

Se true, grava "standalone=yes"; se false, ele grava "standalone=no".If true, it writes "standalone=yes"; if false, it writes "standalone=no".

Exceções

Este não é o primeiro método de gravação chamado após o construtor.This is not the first write method called after the constructor.

- ou --or-

Um método XmlWriter foi chamado antes do término de uma operação assíncrona anterior.An XmlWriter method was called before a previous asynchronous operation finished. Nesse caso, InvalidOperationException será gerado com a mensagem “Uma operação assíncrona já está em andamento”.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

Comentários

O nível de codificação do documento é determinado pela forma como o gravador é implementado.The encoding level of the document is determined by how the writer is implemented. Por exemplo, se um Encoding objeto for especificado no XmlTextWriter Construtor, isso determinará o valor do atributo Encoding.For example, if an Encoding object is specified in the XmlTextWriter constructor, this determines the value of the encoding attribute.

Quando WriteStartDocument é chamado, o gravador valida que o que você está gravando é um documento XML bem formado.When WriteStartDocument is called, the writer validates that what you are writing is a well-formed XML document. Por exemplo, ele verifica se a declaração XML é o primeiro nó, se um e apenas um elemento de nível raiz existe, e assim por diante.For example, it checks that the XML declaration is the first node, that one and only one root-level element exists, and so on. Se esse método não for chamado, o gravador assumirá que um fragmento XML está sendo gravado e não aplicará nenhuma regra de nível de raiz.If this method is not called, the writer assumes an XML fragment is being written and applies no root level rules.

Se WriteStartDocument tiver sido chamado e o WriteProcessingInstruction método for usado para criar outra declaração XML, uma exceção será lançada.If WriteStartDocument has been called and then the WriteProcessingInstruction method is used to create another XML declaration, an exception will be thrown.

Para obter a versão assíncrona desse método, consulte WriteStartDocumentAsync .For the asynchronous version of this method, see WriteStartDocumentAsync.

Aplica-se a

WriteStartDocument()

Quando substituído em uma classe derivada, grava a declaração XML com a versão "1.0".When overridden in a derived class, writes the XML declaration with the version "1.0".

public:
 abstract void WriteStartDocument();
public abstract void WriteStartDocument ();
abstract member WriteStartDocument : unit -> unit
Public MustOverride Sub WriteStartDocument ()

Exceções

Este não é o primeiro método de gravação chamado após o construtor.This is not the first write method called after the constructor.

- ou --or-

Um método XmlWriter foi chamado antes do término de uma operação assíncrona anterior.An XmlWriter method was called before a previous asynchronous operation finished. Nesse caso, InvalidOperationException será gerado com a mensagem “Uma operação assíncrona já está em andamento”.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

Comentários

O nível de codificação do documento é determinado pela forma como o gravador é implementado.The encoding level of the document is determined by how the writer is implemented. Por exemplo, se um Encoding objeto for especificado no XmlTextWriter Construtor, isso determinará o valor do atributo Encoding.For example, if an Encoding object is specified in the XmlTextWriter constructor, this determines the value of the encoding attribute. Esse método não cria um atributo autônomo.This method does not create a standalone attribute.

Quando WriteStartDocument o é chamado de gravador valida que o que você está gravando é um documento XML bem formado.When WriteStartDocument is called the writer validates that what you are writing is a well-formed XML document. Por exemplo, ele verifica se a declaração XML é o primeiro nó, se um e apenas um elemento de nível raiz existe, e assim por diante.For example, it checks that the XML declaration is the first node, that one and only one root-level element exists, and so on. Se esse método não for chamado, o gravador assumirá que um fragmento XML está sendo gravado e não aplicará nenhuma regra de nível de raiz.If this method is not called, the writer assumes an XML fragment is being written and applies no root level rules.

Se WriteStartDocument tiver sido chamado e o WriteProcessingInstruction método for usado para criar outra declaração XML, uma exceção será lançada.If WriteStartDocument has been called and then the WriteProcessingInstruction method is used to create another XML declaration, an exception will be thrown.

Para obter a versão assíncrona desse método, consulte WriteStartDocumentAsync .For the asynchronous version of this method, see WriteStartDocumentAsync.

Aplica-se a