Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML to datarow
Message
From
13/05/2013 13:27:40
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01573699
Message ID:
01573709
Views:
41
This message has been marked as a message which has helped to the initial question of the thread.
>>>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());	
>	}
>}			
Don't think that will work if you want to add the row to an existing table since the Row generated from the XML would not be the same as the row created by DataTable.NewRow().
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform