Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Error saving list items in XML (http://www.go4expert.com/forums/error-saving-list-items-xml-t4356/)

shah123 18May2007 17:01

Error saving list items in XML
 
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 18May2007 17:04

Re: Error saving list items in XML
 
probably the node should be without space or &

shah123 18May2007 17:09

Re: Error saving list items in XML
 
Yup It Worked .. Thanks


All times are GMT +5.5. The time now is 09:39.