Performance of XPath vs DOM

前端 未结 3 768
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 07:00

Would anyone enlighten me some comprehensive performance comparison between XPath and DOM in different scenarios? I\'ve read some questions in SO like xPath vs DOM API, whic

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 07:54

    XPath and DOM are both specifications, not implementations. You can't ask questions about the performance of a spec, only about specific implementations. There's at least a ten-to-one difference between a fast XPath engine and a slow one: and they may be optimized for different things, e.g. some spend a lot of time optimizing a query on the assumption it will be executed multiple times, which might be the wrong thing to do for single-shot execution. The one thing one can say is that the performance of XPath depends more on the engine you are using, and the performance of DOM depends more on the competence of the application programmer, because it's a lower-level interface. Of course all programmers consider themselves to be much better than average...

提交回复
热议问题