XmlTextWriter::WriteRaw Method (String^)

 

Writes raw markup manually from a string.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public:
virtual void WriteRaw(
	String^ data
) override

Parameters

data
Type: System::String^

String containing the text to write.

System_CAPS_noteNote

Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter::Create method and the XmlWriterSettings class to take advantage of new functionality.

This method does not escape special characters.

System_CAPS_security Security Note

The XmlTextWriter does not validate any data that is passed to the WriteRaw method. You should not pass arbitrary data to this method.

The following example writes a string using the WriteRaw method.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{

   // Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;

   // Write the root element.
   writer->WriteStartElement( "Items" );

   // Write a string using WriteRaw. Note that the special
   // characters are not escaped.
   writer->WriteStartElement( "Item" );
   writer->WriteString( "Write unescaped text:  " );
   writer->WriteRaw( "this & that" );
   writer->WriteEndElement();

   // Write the same string using WriteString. Note that the 
   // special characters are escaped.
   writer->WriteStartElement( "Item" );
   writer->WriteString( "Write the same string using WriteString:  " );
   writer->WriteString( "this & that" );
   writer->WriteEndElement();

   // Write the close tag for the root element.
   writer->WriteEndElement();

   // Write the XML to file and close the writer.
   writer->Close();
}

.NET Framework
Available since 1.1
Return to top
Show: