p; stream.Seek(0, SeekOrigin.Begin);
stream.Read(arr, 0, count);
//返回Unicode编码的文本
UnicodeEncoding utf = new UnicodeEncoding();
StreamWriter sw = new StreamWriter(xmlFile);
sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sw.WriteLine(utf.GetString(arr).Trim());
sw.Close();
}
catch( System.Exception ex )
{
throw ex;
}
finally
{
if (writer != null) writer.Close();
}
}
}
}
使用示例
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data;
namespace XmlDesign
{
class Program
{
static void Main(string[] args)
{
DataSet ds = new DataSet();
转换一个XML文件(本地\网络均可)为一个DataSet#region 转换一个XML文件(本地\网络均可)为一个DataSet
//http://news.baidu.com/n?cmd=1&class=sportnews&tn=rss
//F:\study\001CSharp_Study\002Source\XmlDesign\XmlDesign\Save_Plan.xml
ds = XmlDatasetConvert.ConvertXMLFileToDataSet(@"http://news.baidu.com/n?cmd=1&class=sportnews&tn=rss");
Console.WriteLine("数据集名为\"{0}\&qu |