做项目时,为了更方便的检索与使用XMl,我比较习惯用XElement,但是,其他人觉得麻烦,“凡是foreach一下就好了嘛!”,我只能说,时代在变,你们Outer了,两种不同的xml解析方式在代码维护方面带来了不少的麻烦,但我们并不愿意妥协,下面讲讲我遇到的问题,比较一下两种解析方式的不同。
命名空间:
XmlDocument:System.Xml;
XElement:System.Xml.Linq;
反序列化:
XmlDocument doc=new XmlDocument();
doc.LoadXml(xmlStr);
XElement xe = XElement.Parse(xmlStr);