Does anyone do DOM navigation anymore?

D

Derek Fountain

I've spent the last few days tinkering with DOM trees and the DOM API. A
couple of years back I wrote a fairly complex application which found the
data it required using this nextSibling, firstChild, sort of navigation. I
recall the development experience wasn't a terribly happy one, and I have
always presumed that XPATH was largely invented to get past all this
mucking about.

So it occurs to me to ask: do people still use the original DOM style
navigation? When is it preferable to XPATH? Why, in short, is the whole
"document hopping" idea not deprecated?!
 
M

Martin Honnen

Derek said:
I've spent the last few days tinkering with DOM trees and the DOM API. A
couple of years back I wrote a fairly complex application which found the
data it required using this nextSibling, firstChild, sort of navigation. I
recall the development experience wasn't a terribly happy one, and I have
always presumed that XPATH was largely invented to get past all this
mucking about.

So it occurs to me to ask: do people still use the original DOM style
navigation? When is it preferable to XPATH? Why, in short, is the whole
"document hopping" idea not deprecated?!

DOM contrary to XPath not only allows navigating the document but also
changing it (you can add nodes, delete nodes, move nodes etc.). And
often you have only a DOM core implementation and no XPath available. Of
course if you have XPath on top of or in addition to DOM then it is in
most cases easier to navigate to a node with XPath.
 
A

Andy Dingley

Derek Fountain said:
So it occurs to me to ask: do people still use the original DOM style
navigation? When is it preferable to XPATH?

XPath returns you a node set, nextSibling returns a node.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top