XmlDocument.load() 怎么样load一个50m的xml

来源:百度知道 编辑:UC知道 时间:2024/09/18 06:54:57
XmlDocument.load() 怎么样load一个50m的xml 我现在一直给我报内存就错误
不对,还是不怎么好!!1楼的那个同志能过滤下大脑在回答吗!

50M的xml????????????
直接打开都会卡死机吧!
更别说代码打开咯!

用流或者streamreader读取指定大小的流试试!
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
FileStream fs = new FileStream("e:\\1.xml", FileMode.Open, FileAccess.Read);
doc.Load(fs);

最后关闭

string path = "d:\\1.xml";
string xml = "<value>asdf</value>";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
//通过文件
doc.Load(path);
//通过字符串
doc.LoadXml(xml);