Setting StandAlone = Yes in .Net when serializing an object

Viewed 11507

In the following code I want to set "standalone = yes" to the xml, how can I do this?

Dim settings As New Xml.XmlWriterSettings
settings.Encoding = encoding

Using stream As New IO.MemoryStream, xtWriter As Xml.XmlWriter = _
    Xml.XmlWriter.Create(stream, settings)
    serializer.Serialize(xtWriter, obj)
    Return encoding.GetString(stream.ToArray())
End Using

For example, I have this:

<?xml version="1.0" encoding="utf-8"?>

But I want this:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2 Answers
Related