LINQ to XML vs. XmlReader

江枫思渺然 提交于 2019-12-05 09:39:51

PROs of Linq to XML

  • Query XML documents with the same LINQ syntax your used to
  • Uses the same X objects that you're used to working with (XElement, etc.)

PROs of using XmlReader

  • Finer grain control over the query syntax (XPath rather than LINQ)

...personally, I switched to LINQ to XML when it was first introduced and never looked back. Haven't noticed any significant performance degradation as of yet.

I would just use LINQ to XML in Silverlight.

The one advantage that XmlReader has over LINQ is that it doesn't build a DOM in memory but rather moves over an existing stream. However this difference only really comes into its own if you can start processing the stream as its arriving rather than waiting for the entire content to arrive. This advantage is quite difficult to acheive and only rarely useful.

LINQ to XML is much more straight forward to query and considerably more flexiable to use, the trade off is some extra memory.

LINQ to XML is easier however it requires referencing in System.XML.Linq which increases the number of assemblies your Silverlight application will need to load in. so depending on your situation and your feeds, it sometimes is useful to use XMLReader.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!