asp.net读取Xml文件到DataSet,以及DataSet保存为Xml,利用自带的强大功能

2016-12-30 09:57:36来源:oschina作者:深圳大道人点击

第七城市


The Chi-lites
Soul
A lonely man
1972


Babyface
R&B
unknown



Babyface
R&B
The essential babyface
2001


Babyface
R&B
Grown and sexy
2005


Maria Arredondo
Pop
Not going under
2004


Leona Lewis
Pop
Unknown
2008


Usher
R&B
Usher
2008


Christina Aguilera
Blues
Back to basics
2004


Sting
Pop
Shape of my heart



DataSet ds = new DataSet();
TextReader reader = new StringReader(@"


The Chi-lites
Soul
A lonely man
1972


Babyface
R&B
unknown



Babyface
R&B
The essential babyface
2001


Babyface
R&B
Grown and sexy
2005


Maria Arredondo
Pop
Not going under
2004


Leona Lewis
Pop
Unknown
2008


Usher
R&B
Usher
2008


Christina Aguilera
Blues
Back to basics
2004


Sting
Pop
Shape of my heart



");
//读取Xml字符串 用来接收WebService返回数据
//ds.ReadXml(reader, XmlReadMode.Auto);
//读取Xml文件
ds.ReadXml(Server.MapPath("XML/Song.xml"));
//生成Xml文件
//ds.WriteXml(Server.MapPath("xml/song_bak.xml"));
GridView1.DataSource = ds;
GridView1.DataBind(); //读取txt文件
Stream stream = new FileStream(Server.MapPath("XML/demo.txt"), FileMode.OpenOrCreate, FileAccess.Read);
StreamReader readStream = new StreamReader(stream, System.Text.Encoding.GetEncoding("GB2312"));
string SourceCode = readStream.ReadToEnd();
readStream.Close();
Response.Write(SourceCode);
第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台