如何将一个XML的字符串加载到DataSet中

如题
<News>
<NewsCols>
   <Title></Title>
   <Content></Content>
</NewsCols>
</News>
上面表现为字符串,怎样加载到DataSet中
---------------------------------------------------------------
DataSet.ReadXml() 
base on .Net 2.0
---------------------------------------------------------------
Something like
string s = ".........";
System.IO.StringReader reader = new System.IO.StringReader (s);
DataSet ds = new DataSet();
ds.ReadXml(reader);
---------------------------------------------
string str=@"<News>
<NewsCols>
<Title></Title>
<Content></Content>
</NewsCols>
</News>";
//Transfer xml string to DataSet
string NewLine = System.Environment.NewLine;
string s = str.Replace(NewLine,""); 
System.IO.StringReader reader = new System.IO.StringReader(s);
DataSet ds=new DataSet();
ds.ReadXml(reader as System.IO.TextReader);
reader.Close();

posted on 2010-05-18 17:08  一粒沙  阅读(324)  评论(0编辑  收藏  举报