A
Aahz
asp.net 1.1 and C#
Here is code:
xmlfile = new XmlDocument();
xmlfilename = Server.MapPath("doc.xml");
writer = new XmlTextWriter(xmlfilename, System.Text.Encoding.UTF8);
writer.Formatting = System.Xml.Formatting.Indented;
writer.WriteStartDocument(true);
writer.WriteComment("this is a comment");
writer.WriteStartElement("cities");
writer.WriteStartElement("city");
writer.WriteAttributeString("latitude","4.778");
writer.WriteAttributeString("longitude","5.45");
writer.WriteAttributeString("name",namestring);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
xmlfile.Save(xmlfilename);
writer.Flush();
writer.Close();
This is supose to crate and save doc.xml with data but every time I
got error message:
"This an invalid XML document, The document does not have a root
element"
What am I doing wrong ????
Thank you
Here is code:
xmlfile = new XmlDocument();
xmlfilename = Server.MapPath("doc.xml");
writer = new XmlTextWriter(xmlfilename, System.Text.Encoding.UTF8);
writer.Formatting = System.Xml.Formatting.Indented;
writer.WriteStartDocument(true);
writer.WriteComment("this is a comment");
writer.WriteStartElement("cities");
writer.WriteStartElement("city");
writer.WriteAttributeString("latitude","4.778");
writer.WriteAttributeString("longitude","5.45");
writer.WriteAttributeString("name",namestring);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
xmlfile.Save(xmlfilename);
writer.Flush();
writer.Close();
This is supose to crate and save doc.xml with data but every time I
got error message:
"This an invalid XML document, The document does not have a root
element"
What am I doing wrong ????
Thank you