Error saving list items in XML

shah123's Avatar
Contributor
I am getting this error when i add xml code to my application. Basically I am trying to add listitems to XML file.

Code:
private const string filename = "C:\\schedulers.xml";            
XmlTextWriter sch = null;
            sch = new XmlTextWriter(filename, null);
            sch.Formatting = Formatting.Indented;
            sch.Namespaces = false;
try
                {
                    sch.WriteStartDocument();

                    sch.WriteStartElement("", "Schedules", "");

                    sch.WriteStartElement("", "Scheduler", "");
                    sch.WriteString(subjTextbox.Text.ToString());
                    sch.WriteEndElement();

                    sch.WriteStartElement("", "FileName", "");
                    sch.WriteString(textFile.Text.ToString());
                    sch.WriteEndElement();

                    sch.WriteStartElement("", "Date & Time", "");
                    sch.WriteString(date.ToString());
                    sch.WriteEndElement();

                    sch.WriteEndElement();
                    sch.Flush();
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.Message);

                }

Error:

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

A name was started with an invalid character. Error processing resource 'file:///C:/schedulers.xml'. Line 5, Position 9

<Date & Time>18/05/2007 02:02:00</Date & Time>
--------^


please help
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
probably the node should be without space or &
shah123's Avatar
Contributor
Yup It Worked .. Thanks