XmlDocument vs XElement
程序员文章站
2022-07-04 22:39:45
``` var xmlstr = @" some_appid 1413192605 component_verify_ticket some_verify_ticket "; Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i ......
var xmlstr = @"<xml> <appid>some_appid</appid> <createtime>1413192605</createtime> <infotype>component_verify_ticket</infotype> <componentverifyticket>some_verify_ticket</componentverifyticket> </xml>"; stopwatch sw = stopwatch.startnew(); for (int i = 0; i < 1000; i++) { xmldocument doc = new xmldocument(); doc.xmlresolver = null; xmlnode root; doc.loadxml(xmlstr); root = doc.firstchild; var sencryptmsg = root["componentverifyticket"].innertext; } sw.stop(); var docts = sw.elapsedmilliseconds; sw.restart(); for (int i = 0; i < 1000; i++) { xelement xe = xelement.parse(xmlstr); var sencryptmsg = xe.element("componentverifyticket").value; } sw.stop(); messagebox.show(docts + "," +sw.elapsedmilliseconds.tostring());
xmldocumentd的耗时大概是xelement 的4倍以上
推荐阅读
-
VS2013安装提示必须安装ie10的解决办法
-
vs2012不能新建项目怎么办?vs2012新建项目的详细教程
-
VS2013启动调试出错的解决方法
-
vs2012如何设置字体颜色和大小?
-
C# VS2019 WebService创建与发布,并部署到Windows Server 2012R
-
vs2010 中文版下载地址及可用CDKEY 多个地址打包下载
-
VS2010破解版迅雷电驴下载 visual studio2010简体中文正式旗舰版破解版下载(附序列号)
-
vs2010 MSDN文档安装图文方法
-
VS2010执行剪贴、复制时,提示内存不足的官方补丁
-
使用VS2019在WSL中开发调试.NET Core