Cuando se reemplaza en una clase derivada, escribe el contenido de texto especificado.
Espacio de nombres: System.Xml
Ensamblado: System.Xml (en system.xml.dll)
Visual Basic (Declaración)
Public MustOverride Sub WriteString ( _
text As String _
)
Dim instance As XmlWriter
Dim text As String
instance.WriteString(text)
public abstract void WriteString (
string text
)
public:
virtual void WriteString (
String^ text
) abstract
public abstract void WriteString (
String text
)
public abstract function WriteString (
text : String
)
Parámetros
- text
Texto que se va a escribir.
| Tipo de excepción | Condición |
|---|
ArgumentException | La cadena de texto contiene un par suplente no válido. |
WriteString realiza lo siguiente:
-
Los caracteres &, < y > se reemplazan por &, < y >, respectivamente.
-
Los valores de carácter comprendidos en el intervalo de 0x a 0x1F (excluidos los caracteres de espacio en blanco 0x9, 0xA y 0xD) se reemplazan por entidades de caracteres numéricos (de � a �x1F).
-
Si se llama a WriteString en el contexto de un valor de atributo, las comillas dobles y simples se reemplazan por " y ', respectivamente.
Por ejemplo, esta cadena de entrada test<item>test se escribe como
Si text es referencia null (Nothing en Visual Basic) o String.Empty, este método escribe un nodo de texto sin contenido de datos.
En el siguiente ejemplo, se escribe un nodo XML.
Option Explicit
Option Strict
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
' Create a writer to write XML to the console.
Dim settings As XmlWriterSettings = new XmlWriterSettings()
settings.Indent = true
settings.OmitXmlDeclaration = true
Dim writer As XmlWriter = XmlWriter.Create(Console.Out, settings)
' Write the book element.
writer.WriteStartElement("book")
' Write the title element.
writer.WriteStartElement("title")
writer.WriteString("Pride And Prejudice")
writer.WriteEndElement()
' Write the close tag for the root element.
writer.WriteEndElement()
' Write the XML and close the writer.
writer.Close()
End Sub 'Main
End Class 'Sample
using System;
using System.IO;
using System.Xml;
public class Sample {
public static void Main() {
// Create a writer to write XML to the console.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = true;
XmlWriter writer = XmlWriter.Create(Console.Out, settings);
// Write the book element.
writer.WriteStartElement("book");
// Write the title element.
writer.WriteStartElement("title");
writer.WriteString("Pride And Prejudice");
writer.WriteEndElement();
// Write the close tag for the root element.
writer.WriteEndElement();
// Write the XML and close the writer.
writer.Close();
}
}
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
// Create a writer to write XML to the console.
XmlWriterSettings^ settings = gcnew XmlWriterSettings;
settings->Indent = true;
settings->OmitXmlDeclaration = true;
XmlWriter^ writer = XmlWriter::Create( Console::Out, settings );
// Write the book element.
writer->WriteStartElement( L"book" );
// Write the title element.
writer->WriteStartElement( L"title" );
writer->WriteString( L"Pride And Prejudice" );
writer->WriteEndElement();
// Write the close tag for the root element.
writer->WriteEndElement();
// Write the XML and close the writer.
writer->Close();
return 1;
}
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Compatible con: 2.0, 1.0
XNA Framework
Compatible con: 1.0