huckfinn19
Programmer
Hi!
My goal is to create a typed dataset from an XML file, meaning that I don't want all columns to be strings, but also integers, floats and so on. The thing is that at run-time, I know about the types of the fields to be created, but I don't have this information in a .xsd or .dtd file and don't want to use schemas in other files.
So here is an example XML file:
<?xml version="1.0" encoding="utf-8" ?>
<config xmlns=" <params>
<SomeFloat>0.25</SomeFloat>
<SomeInt>25</SomeInt>
<SomeString>A string</SomeString>
</params>
</config>
I know at run-time that SomeFloat is a float, SomeInt an int and son on. I want to load the XML with somthing like :
----------
m_Dataset = new DataSet();
m_Dataset.ReadXml("simple.xml");
//Linking dataset to datasource
DataGrid datagrid = new DataGrid();
dataGrid1.DataSource = m_Dataset;
//Selecting the node that is of interest
dataGrid1.DataMember = "params";
dataGrid1.CaptionText = dataGrid1.DataMember;
----------
How can I make sure that the type of the columns won't be only strings? How can I specify these types? Should I create the table in the dataset first?
Thanks!
Huck
My goal is to create a typed dataset from an XML file, meaning that I don't want all columns to be strings, but also integers, floats and so on. The thing is that at run-time, I know about the types of the fields to be created, but I don't have this information in a .xsd or .dtd file and don't want to use schemas in other files.
So here is an example XML file:
<?xml version="1.0" encoding="utf-8" ?>
<config xmlns=" <params>
<SomeFloat>0.25</SomeFloat>
<SomeInt>25</SomeInt>
<SomeString>A string</SomeString>
</params>
</config>
I know at run-time that SomeFloat is a float, SomeInt an int and son on. I want to load the XML with somthing like :
----------
m_Dataset = new DataSet();
m_Dataset.ReadXml("simple.xml");
//Linking dataset to datasource
DataGrid datagrid = new DataGrid();
dataGrid1.DataSource = m_Dataset;
//Selecting the node that is of interest
dataGrid1.DataMember = "params";
dataGrid1.CaptionText = dataGrid1.DataMember;
----------
How can I make sure that the type of the columns won't be only strings? How can I specify these types? Should I create the table in the dataset first?
Thanks!
Huck