how to read and write to xml using dataset [modified]
-
hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Setting1" value="Very" />
<add key="Setting2" value="Easy" />
</appSettings>
</configuration>for example i found that to read date from xml,i can do this:
DataSet myDS = new DataSet();
myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);Similarly, how can I write to xml using dataset
modified on Thursday, March 4, 2010 7:07 PM
-
hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Setting1" value="Very" />
<add key="Setting2" value="Easy" />
</appSettings>
</configuration>for example i found that to read date from xml,i can do this:
DataSet myDS = new DataSet();
myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);Similarly, how can I write to xml using dataset
modified on Thursday, March 4, 2010 7:07 PM
Dude, A quick Google Search[^] would have led you to the First Search Result.[^] The code from the website is
System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");
custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
xmlSW.Close();I'm not trying to pick on you with all of the links. I am just trying to show that a little searching would give you the answer you need right away. Instead, you had to wait almost 4 hours for me to reply. Good luck writing out your data! Hogan
-
hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Setting1" value="Very" />
<add key="Setting2" value="Easy" />
</appSettings>
</configuration>for example i found that to read date from xml,i can do this:
DataSet myDS = new DataSet();
myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);Similarly, how can I write to xml using dataset
modified on Thursday, March 4, 2010 7:07 PM
ds.WriteXml(fileName);
-
Dude, A quick Google Search[^] would have led you to the First Search Result.[^] The code from the website is
System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");
custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
xmlSW.Close();I'm not trying to pick on you with all of the links. I am just trying to show that a little searching would give you the answer you need right away. Instead, you had to wait almost 4 hours for me to reply. Good luck writing out your data! Hogan
hi, tks for the reply but i noe how to read with your code given. what i'm looking for is how do you proceed after that? with my given xml, how do i get the value of the key and its value. for example:
<add key="Setting1" value="Very" />
how do you get the value of Setting1; and how do you update this value. similarly how do you create new element and value with dataset. i tried using the dataset table but im pretty much lost as it provide null value.