XML to Table inference

  • Thread starter Thread starter Raj Wall
  • Start date Start date
R

Raj Wall

Hi,

I have a simple config.ini to be read into a simple table with three
columns: accountID, port, base_path.

Reading this page:
http://msdn.microsoft.com/library/d...y/en-us/cpguide/html/cpconinferringtables.asp
has led me to try various permutations of XML for my config file (see
example below). Anyway, I need to figure out how to set up the XML and my
code to get the values. Any pointers greatly appreciated!

Regards,
Raj

My code is:
DataSet ds = new DataSet();

ds.ReadXml("config.ini", XmlReadMode.Auto);

DataTable account = ds.Tables["account"];

foreach (DataRow accountRow in account.Rows)

{

ThreadWithState myThread = new ThreadWithState((string)accountRow["port"],
(string)accountRow["account"],(string)accountRow["base_path"],myTWS);

. . .}

And my current config.ini incarnation is:
<?xml version="1.0" standalone="yes"?>

<accounts>

<account>

<accountID>"account1"</accountID>

<port>"port1"</port>

<base_path>"C:\Documents and Settings\Rawall\Desktop\TWS
Accounts\Account1"</base_path>

<!--next account-->

<accountID>"account2"</accountID>

<port>"port2"</port>

<base_path>"C:\Documents and Settings\Rawall\Desktop\TWS
Accounts\Account2"</base_path>

<!--next account-->

<accountID>"account3"</accountID>

<port>"port3"</port>

<base_path>"C:\Documents and Settings\Rawall\Desktop\TWS
Accounts\Account3"</base_path>

</account>

</accounts>
 
Back
Top