DOM text

Richard Lewis richardlewis at fastmail.co.uk
Tue Aug 30 13:05:38 CEST 2005


On Tue, 30 Aug 2005 11:17:25 +0100, "Richard Lewis"
<richardlewis at fastmail.co.uk> said:
> 
> Here is the *complete* code for my SectionCursor class:

In case anyone's interested, I've just noticed a logical error in the
next_node() method:
=================================
def next_node(self):
  if self.current_node.hasChildNodes():
    self.current_node = self.current_node.firstChild
  elif self.current_node.nextSibling is not None:
    self.current_node = self.current_node.nextSibling
  else:
    while self.current_node.parentNode.nextSibling is None\
         and self.current_node != self.section_element:
      self.current_node = self.current_node.parentNode
      if self.current_node != self.section_element:
        self.current_node = self.current_node.parentNode.nextSibling
      else: return False
  self.char_pos = 0
  return True
=================================

which doesn't solve the original problem. Though I think it may be
causing a (related) problem: it says the self.current_node.parentNode is
of NoneType. If there is a problem with assigning parts of an existing
DOM tree to other variables, might this be another symptom?

Cheers,
Richard



More information about the Python-list mailing list