Walking up the DOM tree

Ravikiran Rajagopal ravi at ee.eng.ohio-state.edu
Sun Nov 10 18:27:29 GMT 2002


Hello,
  How do I walk up the DOM tree? The problem is that I cannot use something 
like this because paramters are passed by reference:

DOM::HTMLElement elem = nodeUnderMouse();
while ( !elem.parentNode().tagName().string().contains("HTML") )
{
  elem = elem.parentNode(); // BAD
  kdDebug() << elem.tagName().string() << endl;
}

Is this a C++ question as opposed to a KHtml quesion? I tried to use a 
TreeWalker but the construction of a TreeWalker with all the elements shown 
was beyond my abilities - how do I create a NodeFilter (without subclassing) 
which accepts everything? Anyway, since all I need is to walk up the tree, 
creating a treewalker is probably overkill.

Thanks,
Ravi





More information about the kfm-devel mailing list