Connecting Tech Pros Worldwide Forums | Help | Site Map

XML document must have a top level element error

juli jul
Guest
 
Posts: n/a
#1: Nov 12 '05

Hello ,
I am trying to write to xml document (c#) by this code:
XmlTextWriter xml_writer=null;
xml_writer=new XmlTextWriter("Database.xml",null);
xml_writer.WriteStartDocument();
xml_writer.WriteStartElement("", "Account", "");


The problem is that when I am trying to open the xml I see there such an
error (instead of the normal xml doc):

XML document must have a top level element. Error processing resource

Someone can tell me what is wrong?
Thank you very much!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Robbe Morris [C# MVP]
Guest
 
Posts: n/a
#2: Nov 12 '05

re: XML document must have a top level element error


What does the output of the xml look like? Can you post it?

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx



"juli jul" <juli8024@yahoo.com> wrote in message
news:efCuElXJFHA.4060@TK2MSFTNGP14.phx.gbl...[color=blue]
>
> Hello ,
> I am trying to write to xml document (c#) by this code:
> XmlTextWriter xml_writer=null;
> xml_writer=new XmlTextWriter("Database.xml",null);
> xml_writer.WriteStartDocument();
> xml_writer.WriteStartElement("", "Account", "");
>
>
> The problem is that when I am trying to open the xml I see there such an
> error (instead of the normal xml doc):
>
> XML document must have a top level element. Error processing resource
>
> Someone can tell me what is wrong?
> Thank you very much!
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Closed Thread