Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / August 2003

Tip: Looking for answers? Try searching our database.

write XML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 25 Aug 2003 04:07 GMT
I'm trying to write XML and I am quite unsuccessful so far,
I have a very simple application with 1 button and one click handler like
that, does anyone know what's wrong with this few  lines ?
//-----------------------------------
private void button1_Click(object sender, System.EventArgs e)
{
   string file = "test.xml";
   XmlTextWriter xtw = new XmlTextWriter(file, Encoding.UTF8);
   try
   {
       xtw.WriteStartDocument();
       xtw.WriteElementString("Name", "aName");
       xtw.WriteStartElement("Data");
       xtw.WriteElementString("Item", "anItem");
       xtw.WriteElementString("Item", "anItem");
       xtw.WriteElementString("Item", "anItem");
       xtw.WriteEndElement();
       xtw.WriteEndDocument();
   }
   finally { xtw.Close(); }
}

it throws an InvalidOperationExeption() when I try to
WriteStartElement("Data");
Lloyd Dupont - 25 Aug 2003 04:44 GMT
no worries, I found it !
I should have a first line setting the namespace ....

> I'm trying to write XML and I am quite unsuccessful so far,
> I have a very simple application with 1 button and one click handler like
[quoted text clipped - 20 lines]
> it throws an InvalidOperationExeption() when I try to
> WriteStartElement("Data");

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.