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>
You can use Linq to XML for this. Suppose you have a class
Book:And now you have a list of books that you want to put into an XML document:
Now you can just save this
XDocument:This produces: