Check XmlElement.HasAttributes before calling XmlElement.Attributes

I have tested it against Everrette. If an xmlelement you are working with doesn’t contain any attributes, calling XmlElement.Attributes will trigger the system to create an empty ArrayList. The best way to avoid it is to check whether the element contain any attribute before trying to traversing its attributes. foreach(XmlAttriubte attr in element.Attributes) {    //…

0

How to traverse xmlelement.childnodes effectively

I have been working on the performance these days, and I want to share some tricks that you can do to reduce memory allocation significantly if the xml document you are working with is huge. Use XmlElement.FirstChild and next sidbling is a lot cheaper than foreach(xmlnode child in element.ChildNodes).  You can run the CLRProfiler to…

0