Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How to load a subset of data from DataGridView back to XmlDocument

$
0
0

I have an xml file that I want users to be able to edit via a DataGridView.  I am loading just one of the many nodes from the xml file into the DataGridView (including it's child nodes). Can someone help me get the user edited subset of data back into the XmlDocument so I can then save it? Here is the sample xml:

<?xml version="1.0" encoding="utf-8"?><Customer name="TestCustomer" location="Durham, NH"><Device DeviceName="MyDevice1"><DeviceOption FeatureName="Feature Name 1" Value="False" Notes="Notes about this feature 1"></DeviceOption><DeviceOption FeatureName="Feature Name 2" Value="False" Notes="Notes about this feature 2"></DeviceOption><DeviceOption FeatureName="Feature Name 3" Value="27" Notes="Notes about this feature 3"></DeviceOption>		<DeviceOption FeatureName="Feature Name 4" Value="True" Notes="Notes about this feature 4"></DeviceOption></Device><Device DeviceName="MyDevice2"><DeviceOption FeatureName="Feature Name 1" Value="False" Notes="Something about this feature 1"></DeviceOption><DeviceOption FeatureName="Feature Name 2" Value="True" Notes="Something about this feature 2"></DeviceOption><DeviceOption FeatureName="Feature Name 3" Value="18" Notes="Something about this feature 3"></DeviceOption>		<DeviceOption FeatureName="Feature Name 4" Value="True" Notes="Something about this feature 4"></DeviceOption></Device></Customer>

Once I find the Device XmlNode I'm looking for I load the DataGridView with the child nodes like this:

private void FillGridWithOEDeviceOptions(XmlNode node1) { XmlReader xr = new XmlNodeReader(node1); DataSet ds = new DataSet(); ds.ReadXml(xr); dataGridView1.DataSource = ds.Tables["DeviceOption"];

}

Can someone help me get the user edited subset of data back into the XmlDocument so I can then save it?

Thanks in advance.


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>