[Mono-list] Datasets passed between methods loses data

Atsushi Eno atsushi@ximian.com
Mon, 07 Mar 2005 19:07:26 +0900


Hello,

Actually it depends on the content of "server.log" since the XML
structure is not determined only with that code. If that log file
contains only simple text (BTW that code is really not recommended
because it will raise an XmlException if there is broken XML
fragment), it won't return any XML content, since that simple text
content is not mapped to any DataTable, nor the "root" element is
not regarded as a DataTable.

DataSet is not such universal XML store. It just holds such contents
that is mappable to table set structure and ReadXml() ignores
other content. Just FYI, MS.NET also ignores the text content.

Atsushi Eno

anthony whalley wrote:
> Hi All 
> 
> I am writing an application that marshells a log4net 
> file into a dataset and then passes the dataset
> over to another method. I am using v 1.1.4 from the 
> RPMs on Suse 9.2 and below is the code.
> However when I test the dataset returned it 
> has only a root node even though before
> it is passed it has all the data inside it. 
> I have solved the prolem for now by passing over
> the data as a string type and marhalling the 
> data there but wondered if I should
> report it as a bug?? 
> 
> public class obj{
> 		public DataSet GetLogFile()
> 		{
> 			DataSet ds = new DataSet() ;
> 			try 
> 			{
> 				string _logLocation = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "server.log" ;
> 				Stream stm = File.Open(_logLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) ;
> 				
> 				StreamReader str = new StreamReader(stm) ;
> 				ds.ReadXml(new StringReader("<root xmlns:log4net='http://logging.apache.org/log4net/LogSchema'>" + 
> 					str.ReadToEnd() + 
> 					"</root>")) ;
> 				str.Close();
> 				stm.Close();
> 				
> 			}
> 			catch(Exception e)
> 			{
> 				log.Error("Get log file error", e) ; 
> 			}
> 			return ds ;
> 		}
> }
> 
> public class otherObj
> {
> 
>   obj o = new obj() ;
>   DataSet ds = new DataSet() ;
>   public void testxml(){
>   ds = o.GetLogFile() ;
>   Console.WriteLine(ds.GetXml()); //returns <root />
> }
> }
> 
> 
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>