之前读取xml文档的时候,都是一下子把所有的节点都读到内存当中,很愚蠢的方法。xml文件在100mb以上的时候,读取会花费一秒左右的时间,费时间。最近刚学习到一个新方法,一个C#中类似于数据库操作的方法,看代码。
XDocument xdoc = XDocument.Load(XmlPath);
XElement selectInfo = (from info in xdoc.Descendants(type)
select info).Single();
想用哪一个节点内的内容,直接操作selectInfo就好啦。
记一下,和不知道的朋友分享。
https://www.cnblogs.com/z_lb/archive/2012/04/27/2473696.html
这位大神写的很清楚