all groups > dotnet sdk > august 2003 >
You're in the

dotnet sdk

group:

write XML


write XML Lloyd Dupont
8/25/2003 1:07:49 PM
dotnet sdk:
I'm trying to write XML and I am quite unsuccessful so far,
I have a very simple application with 1 button and one click handler like
that, does anyone know what's wrong with this few lines ?
//-----------------------------------
private void button1_Click(object sender, System.EventArgs e)
{
string file = "test.xml";
XmlTextWriter xtw = new XmlTextWriter(file, Encoding.UTF8);
try
{
xtw.WriteStartDocument();
xtw.WriteElementString("Name", "aName");
xtw.WriteStartElement("Data");
xtw.WriteElementString("Item", "anItem");
xtw.WriteElementString("Item", "anItem");
xtw.WriteElementString("Item", "anItem");
xtw.WriteEndElement();
xtw.WriteEndDocument();
}
finally { xtw.Close(); }
}

it throws an InvalidOperationExeption() when I try to
WriteStartElement("Data");

Re: write XML Lloyd Dupont
8/25/2003 1:44:59 PM
no worries, I found it !
I should have a first line setting the namespace ....

"Lloyd Dupont" <[bad.user=lloyd;good.user=ld]@[server=galador.net]> wrote in
message news:O6tbGYraDHA.2928@tk2msftngp13.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button