Lloyd Dupont
8/25/2003 3:45:00 AM
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...
> 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");
>
>