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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:51+00:00 2026-05-27T11:09:51+00:00

How to to write .xml file with this string? string: string string1 = textbox1.text;

  • 0

How to to write .xml file with this string?

string:

string string1 = textbox1.text;
string string2 = textbox2.text;
string string3 = textbox3.text;
string string4 = textbox4.text;

the xml file result:

<?xml version="1.0" encoding="utf-8" ?>
        <books>
            <book Title="Pure JavaScript" Price=string1/>
            <book Title="Effective C++" Price=string2/>
            <book Title="Assembly Language: Step-By-Step" Price=string3/>
            <book Title="Oracle PL/SQL Best Practices" Price=string4/>
        </books>
  • 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-27T11:09:52+00:00Added an answer on May 27, 2026 at 11:09 am

    You can use Linq to XML for this. Suppose you have a class Book:

    class Book
    {
        public string Title { get; set; }
        public decimal Price { get; set; }
    }
    

    And now you have a list of books that you want to put into an XML document:

    List<Book> books = new List<Book>();
    books.Add(new Book() { Title = "Pure JavaScript", Price = 59.0M});
    
    XDocument xdoc = new XDocument(new XElement("books", books.Select( x=> new XElement("book", 
                                   new XAttribute("Title", x.Title), 
                                   new XAttribute("Price", x.Price)))));
    

    Now you can just save this XDocument:

    xdoc.Save("text.xml");
    

    This produces:

    <books>
      <book Title="Pure JavaScript" Price="59.0" />
    </books>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an XML file with UTF-8 encode, and the original string
This works: using (StreamWriter stw = new StreamWriter(Server.MapPath(\\xml\\file.xml))) { stw.Write(xmlEncStr); } This creates an
I have to write an XML file using java.The contents should be written from
I want to write a XML file as below: <?xml version=1.0 encoding=UTF-8?> <books xmlns:xsd=http://www.w3.org/2001/XMLSchema
I want to write a .xml file using the following code into the App_Data/posts.
How to read the below xml file and write its content into a plain
I am trying to write a servlet that will send a XML file (xml
I need to generate an XML file in C#. I want to write the
I need to write an error log to a XML file using Visual Basic
I want to write the bulk of data into xml file ,the data coming

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.