DOMDocument programming: a lot of little dilemmas, how to solve them?

Posted by Peter Krauss on Programmers See other posts from Programmers or by Peter Krauss
Published on 2013-11-02T22:53:03Z Indexed on 2013/11/03 16:10 UTC
Read the original article Hit count: 220

Filed under:

I need elegance and performance: how to decide by the "best implementation" for each DOM algorithm that I face. This simple "DOMNodeList grouper" illustrate many little dilemmas:

  • use iterator_to_array or "populate an array", when not all items need to be copied.
  • use clone operator, cloneNode method or import method?
  • use parentNode::method() or documentElement::method? (see here)
  • first removeChild or first replaceChild, no avoids "side effects"?
  • ...

My position, today, is only "do an arbitrary choice and follow it in all implementations" (like a "Convention over configuration" principle)... But, there are another considerations? About performance, there are some article showing benchmarks?


PS: this is a generic DOM question, any language (PHP, Javascript, Python, etc.) have the problem.

© Programmers or respective owner

Related posts about dom