XmlWriter.Create Method (TextWriter, XmlWriterSettings)
Assemblies: System.Xml (in System.Xml.dll)
System.Xml.ReaderWriter (in System.Xml.ReaderWriter.dll)
'Declaration Public Shared Function Create ( _ output As TextWriter, _ settings As XmlWriterSettings _ ) As XmlWriter
- Type: System.IO.TextWriter
- Type: System.Xml.XmlWriterSettings
If the XmlWriter is being used with the Transform method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. This ensures that the created XmlWriter object has the correct output settings.
The following example writes out an XML string.
Dim settings As New XmlWriterSettings() settings.OmitXmlDeclaration = True Dim sw As New StringWriter() Using writer As XmlWriter = XmlWriter.Create(sw, settings) writer.WriteStartElement("book") writer.WriteElementString("price", "19.95") writer.WriteEndElement() writer.Flush() Dim output As String = sw.ToString() End Using