2

Well, Say I am working on a project that is gonna have lots of people online simultaneously and I need to provide them with data coming from some XML files. What would be the best way to do that when it comes to performance issues? Is there any real differences between xPath or DOM or I shouldn't care and just go ahead and use the one I like most?

Additionally, what is the problem using RegEx to parse a xml or xhtml file?

Delta
  • 4,308
  • 2
  • 29
  • 37
  • 2
    you cannot "like" something that you don't know. Start learning XML and XPath and you won't be sorry. :) I would even recommend ... gasp ... XSLT to you. :) – Dimitre Novatchev Jan 20 '11 at 03:21
  • 2
    Actually I already know very well how to use both xPath and DOM and I don't know why did you assume that I don't, but thanks. – Delta Jan 20 '11 at 03:45
  • Asking two questions in one post is a bad idea. Please ask the regex question separately (except that it's probably been well answered before) – Michael Kay Jan 20 '11 at 09:35

2 Answers2

7

If you're interested in performance, then there may be tree models that perform much faster than DOM (for example, if you're in the Java world, XOM) and that also offer much better usability.

XPath is a high-level language, DOM APIs are much lower level. The main difference is therefore programmer productivity, ease of maintenance, etc. As to performance, a high-level language will usually be slower than a top-class programmer writing super-optimized code with a lower-level interface, but faster than an average programmer writing average code against a deadline.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • +1 Very good answer enlightening misunderstood concepts: tree models (DOM vs XOM, etc.) and high-level (XPath) vs. low-level (DOM methods) language. –  Jan 22 '11 at 17:42
1

Use whichever you want, the performance difference is likely negligible. As to your last question, please see this answer:

https://stackoverflow.com/questions/1732454

Community
  • 1
  • 1
Jonah
  • 9,991
  • 5
  • 45
  • 79