Solved

Codes not generate the file properly

Posted on 2013-06-25
1
199 Views
Last Modified: 2013-06-30
Hi,
I don't know why these codes below are not creating any .xml file when I run the project.
                    string FILENAME = Server.MapPath("~") + "..\\..\\xml\\common.xml";
                    ?XmlTextWriter textwrt = new XmlTextWriter(FILENAME, null);
                    textwrt.WriteStartDocument();
                    textwrt.WriteStartElement("Common");
                    textwrt.WriteAttributeString("field1", tb_fld1.Text);
                    textwrt.WriteAttributeString("field2", tb_fld2.Text);
                    textwrt.WriteEndElement();
                    textwrt.Close();

Open in new window

0
Comment
Question by:HuaMinChen
1 Comment
 
LVL 42

Accepted Solution

by:
sedgwick earned 110 total points
ID: 39277313
use this instead:
  string FILENAME = Server.MapPath("~") + "..\\..\\xml\\common.xml";
 XDocument xdoc = new XDocument();
            xdoc.Add(new XElement("common", new XAttribute("field1", 1), new XAttribute("field2", 2)));
            xdoc.Save(FILENAME);

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# guarantee sql connection close 6 39
Jquery/JSON passing value from one function to another 12 36
Printing 1 51
VB.Net - MemoryMappedFiles - Confirm receipt 2 18
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question