I am trying to create the following xml file with VS 2005:
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile
xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)" GeneratedClassNamespace=""
GeneratedClassName="Extra">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings>
<Setting Name="Birth" Type="System.DateTime" Scope="Application">
<Value Profile="(Default)">15-09-1959</Value>
</Setting>
<Setting Name="SpecialColor" Type="System.Drawing.Color"
Scope="Application">
<Value Profile="(Default)">255; 192; 128</Value>
</Setting>
</Settings>
</SettingsFile>
I use the following code:
Dim Settings As New XmlWriterSettings
Settings.Indent = True
Settings.NewLineOnAttributes = True
Dim wr As XmlWriter = XmlWriter.Create("output.settings", Settings)
wr.WriteStartElement("SettingsFile")
' ****** This is the problem-line ******
wr.WriteAttributeString("xmlns",
"http://schemas.microsoft.com/VisualStudio/2004/01/settings")
wr.WriteAttributeString("CurrentProfile", "(Default)")
wr.WriteAttributeString("GeneratedClassNamespace", "")
wr.WriteAttributeString("GeneratedClassName", "Instellingen")
wr.WriteStartElement("Profiles")
etc. etc.
The line that starts to write the attribute xmlns is giving me problems. It
generates an exception:
The prefix '' cannot be redefined from '' to
'http://schemas.microsoft.com/VisualStudio/2004/01/settings' within the same
start element tag.
All the other lines work, but I need the xmlns attribute there.