PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET XML to Table inference

Reply

XML to Table inference

 
Thread Tools Rate Thread
Old 11-04-2006, 08:25 PM   #1
Raj Wall
Guest
 
Posts: n/a
Default XML to Table inference


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...rringtables.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>



  Reply With Quote
Old 12-04-2006, 06:34 AM   #2
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: XML to Table inference

Raj,

If everything fails to get an XML file will this mostly do it.

http://www.vb-tips.com/default.aspx...6a-22589f018cd4

I hope this helps,

Cor

"Raj Wall" <metanalogy@nospam.nospam> schreef in bericht
news:%23oEkg2ZXGHA.3684@TK2MSFTNGP05.phx.gbl...
> 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...rringtables.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>
>
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off