XmlDocument vs XElement
程序员文章站
2022-04-10 13:52:58
``` 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倍以上
上一篇: 冬天的水果有哪些,吃哪些水果好
下一篇: 虾怎么煮?简单几步,就可以煮出好吃的虾