Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML to datarow
Message
 
 
À
13/05/2013 13:04:39
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01573699
Message ID:
01573706
Vues:
30
>>Hi everybody,
>>
>>We're passing XML like this
>>
>>
>>"<tcactionlist><BACKCOLOR>16496253</BACKCOLOR><BarIndex>1</BarIndex>
>><BarKeyID>YEM918Z</BarKeyID><BARTYPE></BARTYPE><Base_ID>0</Base_ID>
>><Booking_ID></Booking_ID><category>SNOWBOARD</category><CLIP_LOC></CLIP_LOC>
>><CLIP_SP></CLIP_SP><Clipboard></Clipboard><CRITERIA1>0</CRITERIA1><CRITERIA2>.F.</CRITERIA2><CRITERIA3>.F.</CRITERIA3>
>><CRITERIA4>0</CRITERIA4><CRITERIA5>0</CRITERIA5><CRITERIA6>0</CRITERIA6>
>><CRITERIA7>2</CRITERIA7><Date_time>04/30/2013 16:59:00</Date_time></tcactionlist>"
>>
>>
>>Basically, it's a table's row. We don't necessary pass every column with value.
>
>But you do have an XML element for each column ? And the values, where supplied, are quaranteed to be the correct type ?
>
I am not sure I have the element for each column. The sample I found is not completely written (I guess it's because we don't write the whole invoke string). The sample I found was truncated at date_time value.

BTW, this is what I tried in the meantime and quick test seemed to work
string xml = @"<b_sched><BACKCOLOR>16496253</BACKCOLOR><BarIndex>1</BarIndex>
<BarKeyID>YEM918Z</BarKeyID><BARTYPE></BARTYPE><Base_ID>0</Base_ID>
<Booking_ID></Booking_ID><category>SNOWBOARD</category><CLIP_LOC></CLIP_LOC><CLIP_SP></CLIP_SP>
<Clipboard></Clipboard><CRITERIA1>0</CRITERIA1><CRITERIA2>false</CRITERIA2><CRITERIA3>false</CRITERIA3>
<CRITERIA4>0</CRITERIA4><CRITERIA5>0</CRITERIA5><CRITERIA6>0</CRITERIA6><CRITERIA7>2</CRITERIA7>
<Date_time>04/30/2013 16:59:00</Date_time></b_sched>";
			DataSet ds = new DataSet();
			ds.ReadXml(new XmlTextReader(new StringReader(xml)));
			
foreach (DataRow row in ds.Tables[0].Rows)
{
	foreach (DataColumn column in ds.Tables[0].Columns)
	{
		Console.WriteLine (column.ColumnName + ":  " + row[column.ColumnName].ToString());	
	}
}			
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform