What is more efficient for parsing Xml, XPath with XmlDocuments, XSLT or Linq?

后端 未结 4 2068
北海茫月
北海茫月 2021-02-02 09:25

I have parsed XML using both of the following two methods...

  • Parsing the XmlDocument using the object model and XPath queries.
  • XSL/T

But I

4条回答
  •  离开以前
    2021-02-02 09:51

    LinqToXml queries work against the IEnumerable contract... most of its operations are O(N) because they require iteration over the IEnumerable.

    If what you're starting with is a string containing xml, in order to work with it in Linq, you would need to parse it into the full object graph using XElement.Parse, then iterate over parts of it (to filter it, for example).

    My understanding of XPath is that it will filter while parsing, which could be very advantageous from a performance standpoint. The full object graph need not be constructed.

提交回复
热议问题