Rustom Mody wrote:
I am trying to write a recursive filter to remove whitespace-only
nodes for minidom.
The code is below.
Strangely it deletes some whitespace nodes and leaves some.
If I keep calling it -- like so: fws(fws(fws(doc))) then at some
stage all the ws nodes disappear
Does anybody have a clue?
Yup, don't stand on the limb you are sawing off.
def fws(ele):
...
for c in ele.childNodes:
if isWsNode(c):
ele.removeChild(c)
...
At the very least:
for c in reversed(ele.childNodes):
if isWsNode(c):
ele.removeChild(c)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list