Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Codes not generate the file properly

Posted on 2013-06-25
1
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 440 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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