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 3725456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T07:00:52+00:00 2026-05-19T07:00:52+00:00

I have this string variable: string xml = @<Contacts> <Contact> <Name>Patrick Hines</Name> <Phone Type=Home>206-555-0144</Phone>

  • 0

I have this string variable:

string xml = @"<Contacts> 
    <Contact> 
    <Name>Patrick Hines</Name> 
    <Phone Type=""Home"">206-555-0144</Phone> 
    <Phone Type=""Work"">425-555-0145</Phone> 
    <Phone Type=""Mobile"">332-899-5678</Phone> 
    <Address> 
        <Street1>123 Main St</Street1> 
        <City>Mercer Island</City> 
        <State>WA</State> 
        <Postal>68042</Postal> 
    </Address> 
    </Contact> 
    <Contact> 
    <Name>Dorothy Lee</Name> 
    <Phone Type=""Home"">910-555-1212</Phone> 
    <Phone Type=""Work"">336-555-0123</Phone> 
    <Phone Type=""Mobile"">336-555-0005</Phone> 
    <Address> 
        <Street1>16 Friar Duck Ln</Street1> 
        <City>Greensboro</City> 
        <State>NC</State> 
        <Postal>27410</Postal> 
    </Address> 
    </Contact>
</Contacts>";

How can I save this string into an XML file in my drive c? Using c#.

  • 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-19T07:00:54+00:00Added an answer on May 19, 2026 at 7:00 am

    The fact that it’s XML is basically irrelevant. You can save any text to a file very simply with File.WriteAllText:

    File.WriteAllText("foo.xml", xml);
    

    Note that you can also specify the encoding, which defaults to UTF-8. So for example, if you want to write a file in plain ASCII:

    File.WriteAllText("foo.xml", xml, Encoding.ASCII);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XSLT, I have a variable which contains a string. This string contains
I have this xml/soap from a sharepoint webservice call: <GetAllUserCollectionFromWeb xmlns=http://schemas.microsoft.com/sharepoint/soap/directory/> <Users> <User ID=ID
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
I have defined an XML string using $str = <a><b></b></a> Now I want to
I'm following this turorial on parsing XML with XPath, and it gives the following
I have a ViewGroup defined in XML with a view inside, at onCreate time
How can i remove preprocessing instructions from an XML in a greener way? suppose
I have two flash movies fl_base and fl_top . fl_base contains ActionScript that pulls
I have to resolve a problem close to parsing a huge file like, 3

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.