Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:01:08+00:00 2026-05-31T05:01:08+00:00

Having an issue opening, changing, and then saving changes to an XML file using

  • 0

Having an issue opening, changing, and then saving changes to an XML file using Linq to XML.

Here’s my code:

XDocument doc = XDocument.Load("xml/Campaigns.xml");

        XElement newCampaign = new XElement("campaign",
               new XAttribute("id", "2"),
               new XElement("name", "new campaign")
               );
        doc.Add(newCampaign);
        doc.Save("xml/Campaigns.xml");

I’m not getting any compile errors for opening, creating and adding the XElement, only when I try to save the changes.

The compile errors I’m seeing are: The best overloaded method match for ‘System.Xml.Linq.XElement.Save(System.Xml.XmlWriter)’ has some invalid arguments

and:

Argument 1: cannot convert from ‘string’ to ‘System.Xml.XmlWriter’

I’m not sure why it’s making or expecting me use a XmlWriter because according to this I can save a string in the Save Method:

http://msdn.microsoft.com/en-us/library/bb345830.aspx

If anyone could help, I’d be grateful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:01:10+00:00Added an answer on May 31, 2026 at 5:01 am

    My guess is you’re using Silverlight (e.g. on Windows Phone 7) – where the Save method has fewer overloads. It’s not clear where you’re trying to save the document to, but if you are using Silverlight then you’ll need to use one of the overloads listed in the linked page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VS2010 and having an issue where upon opening my solution the
Having an issue here that I have tried everything I can think of but
having same issue, i am totally new in php. i install XAMPP then download
I'm opening a CSV file and reading values from it using File.open(filename). So I
Having issue with my navigation. How can I prevent it? My CSS file looks
Im having issue with mail sending In web.config file <mailSettings> <smtp from=xxxx@companyname.com> <network host=mail.authsmtp.com
I'm having issue working with json_decode() in PHP. Im using the json2.js library to
I am having an issue opening a thick-box with anchor tags appended to a
I am having a weird issue with my keyboard automatically closing and then reopening
I am having a strange issue opening up my UserControl in Expression Blend when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.