473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

xml writer error


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!
Nov 16 '05 #1
3 2827
juli,

You must close the tags that you have opened, in this case the tag Account.
Do that by calling WriteEndElement().
When you are finished writing the document, call WriteEndDocument().
This method automatically closes any tags still open.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"juli jul" <ju******@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...

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!

Nov 16 '05 #2
Hello,
I tried to do that:
xml_writer.WriteEndElement();
xml_writer.WriteEndDocument();

and still get the error :
XML document must have a top level element. Error processing resource

Thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
And then, of course; finish up calling Close().

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"juli jul" <ju******@yahoo.com> wrote in message
news:ew**************@tk2msftngp13.phx.gbl...
Hello,
I tried to do that:
xml_writer.WriteEndElement();
xml_writer.WriteEndDocument();

and still get the error :
XML document must have a top level element. Error processing resource

Thank you very much!

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

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David McBride | last post by:
I'm getting the following message when I run my Perl script that uses the XML::Writer module: "Processing instruction target begins with 'xml' at .../makeconf/LW/LWTest.pm line 75" The pi()...
0
by: boy | last post by:
Hi all, I have created a simple template class as follow, but i encountered memory leakage on the base.Render(writer). Have all you of encountered the same problem? using System; using...
2
by: googleboy | last post by:
Hi. I am trying to write out a csv file with | instead of comma, because I have a field that may have many commas in it. I read in a csv file, sort it, and want to write it out again. I read...
3
by: juli jul | last post by:
Hello, I declare it in a public function inside a class: XmlTextWriter xml_writer=null; xml_writer=new XmlTextWriter(); and get this error: System.Xml.Writer.XmlTextWriter()' is inaccessible...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Jon Paal | last post by:
why the error ? Compiler Error Message: BC30452: Operator '&' is not defined for types 'System.Web.UI.WebControls.FontUnit' and 'String'. Source Error: Line 203: ...
1
by: tkpmep | last post by:
I expected the following code to work: f = file(fn,"wb") writer = csv.writer(f) for i in range(IMax): writer.writerow(].append( for j in range(N)])) but instead i got the following error...
2
by: Geoff | last post by:
Hello, I have three files: ~~~~~~~~~ people.xml ~~~~~~~~~ <?xml version="1.0"?> <people xmlns:xi="http://www.w3.org/2001/XInclude" > <xi:include href="AlanTuring.xml"/>
6
by: roblugt | last post by:
I have what I imagine is a well-known .Net networking problem, but even though I've Googled for some time I've not yet come across a thread where this has been fully explained... There is a...
0
by: nkumarin001 | last post by:
Hi, If the buffer cache wait events are strictly related to Database Writer I/O activity, then starting I/O slaves is appropriate. If the buffer cache wait events are occuring for...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.