Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<class name="Client" dbtable="CLIENT" codetype="cClient" guid="e8b4e56d-057f-417e-be85-145d9c3f33b0">
    <properties>
      <property class="Client" child="" name="clientID" dbtype="int" codetype="int">
      <property class="Client" child="" name="name" dbtype="string" codetype="string">
      <property class="Client" child="Address" name="addr" dbtype="" codetype="cAddress">




i want to insert data like above in xml file
in button click i want to add the above data into xml file

What I have tried:

i used for Writeline command to add data but data is in table format
Posted
Updated 9-Nov-16 20:05pm
v2
Comments
Member 10329616 10-Nov-16 9:53am    
Thank you i got solution

XElement root;

if (File.Exists(file))
root = XElement.Load(file);
else
root = new XElement("class");

root.Add(new XElement("class",
new XAttribute("name", "Address"),
new XAttribute("dbtable", "ADDRESS"),
new XAttribute("codetype", "cAddress"),
new XAttribute("guid", "3f068e89-cf64-481b-89d7-3f4255d121cf"),
new XElement("properties",
new XElement("property",
new XAttribute("class", "Address"),
new XAttribute("child", ""),
new XAttribute("name", "addressID"),
new XAttribute("dbtype", "int")))
)
);
root.Save(file);



i am using above code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900