Part of an application I'm working on needs to manipulate some XML data (in
an XML file), by reading the data into a DataSet using the MyDataSet.ReadX ML
method, and then using MyDataSet.Write XML to update the XML file itself.
However, now I want to take advantage of the Primary Key functionality of
the DataSet object, so I can easier find rows (in a DataTable in the
DataSet), and also easier remove rows, based on a unique key.
Unfortunately, I'm not sure how that will impact how the XML looks (and I
cannot change the format of that file - it's already used by other
applications).
Here's a snippet of the XML I'm using:
<?xml version="1.0" ?>
<Cache>
<FileCache>
<FileName>Book1 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .26094.60105</OID>
<DateTime>4/5/2005 9:50:45 AM</DateTime>
</FileCache>
<FileCache>
<FileName>Book2 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .18503.25804</OID>
<DateTime>4/5/2005 9:50:56 AM</DateTime>
</FileCache>
</Cache>
The field I need to use as primary key (should be unique) is the OID field.
As you can see, reading that data into a Dataset gives me a DataTable called
Cache, with rows called FileCache (where OID is the third column in those
rows).
How do I tell it to use that column as the primary key, even after I've
loaded it via the LoadXML method, and then how do I do the SaveXML without
adding anything else to the XML layout than what you see above?
Thanks!
an XML file), by reading the data into a DataSet using the MyDataSet.ReadX ML
method, and then using MyDataSet.Write XML to update the XML file itself.
However, now I want to take advantage of the Primary Key functionality of
the DataSet object, so I can easier find rows (in a DataTable in the
DataSet), and also easier remove rows, based on a unique key.
Unfortunately, I'm not sure how that will impact how the XML looks (and I
cannot change the format of that file - it's already used by other
applications).
Here's a snippet of the XML I'm using:
<?xml version="1.0" ?>
<Cache>
<FileCache>
<FileName>Book1 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .26094.60105</OID>
<DateTime>4/5/2005 9:50:45 AM</DateTime>
</FileCache>
<FileCache>
<FileName>Book2 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .18503.25804</OID>
<DateTime>4/5/2005 9:50:56 AM</DateTime>
</FileCache>
</Cache>
The field I need to use as primary key (should be unique) is the OID field.
As you can see, reading that data into a Dataset gives me a DataTable called
Cache, with rows called FileCache (where OID is the third column in those
rows).
How do I tell it to use that column as the primary key, even after I've
loaded it via the LoadXML method, and then how do I do the SaveXML without
adding anything else to the XML layout than what you see above?
Thanks!
Comment