Is XPath much more efficient as compared to DOM and SAX?

前端 未结 5 841
再見小時候
再見小時候 2020-12-07 00:20

I need to parse an xml string and find values of specific text nodes, attribute values etc. I\'m doing this in javascript and was using the DOMParser class for the same. Lat

5条回答
  •  囚心锁ツ
    2020-12-07 01:11

    This document from MSDN provides a wealth of information about optimizing XML processing.

    In particular, the XPathDocument class is designed to be more efficient for evaluating XPath expressions than using (the DOM-based) XmlDocument class. The reason is that XPathDocument is a read-only representation of an XML document, while a DOM implementation also covers changing the document.

    Using DOM has a not less-important downside that it typically results in complicated, spaghetti-like code that is difficult to understand and maintain.

提交回复
热议问题