Dear Friends,
I am using the minidom for my python application. But the problem is that the whitespace in XML document .
My code calling the function is
The called function is
but got error as
Please advise with a quick solution
Thanks
Anes
I am using the minidom for my python application. But the problem is that the whitespace in XML document .
My code calling the function is
Code:
def mostrar_libro(self, lista): # show_book
"""
Method for displaying a book on screen when you load the DBR
"""
self.limpiar_modelo() # clean_model
l = []
for x in range(len(lista)):
try:
#y = lista[x].childNodes
cleanUpNodes(lista[x])
y = lista[x].childNodes
#y = self.cleanUpNodes(lista[x])
#print "y hahaha is: "+y[0].toprettyxml()
z = y[0].firstChild.toprettyxml()
print "data yo yo is "+z
l.append(y[0])
except AttributeError:
pass
iter = self.treestore.append(None, ['%s' % z])
The called function is
Code:
def remove_whilespace_nodes(node):
""" Removes all of the whitespace-only text decendants of a DOM node. """
# prepare the list of text nodes to remove (and recurse when needed)
#global dom
remove_list = []
for child in node:
if child.nodeType == node.TEXT_NODE and not child.data.strip( ):
# add this text node to the to-be-removed list
remove_list.append(child)
elif child.hasChildNodes( ):
# recurse, it's the simplest way to deal with the subtree
remove_whilespace_nodes(child)
# perform the removals
for node in remove_list:
node.parentNode.removeChild(node)
node.unlink( )
but got error as
self.mostrar_libro(lista)
File "/usr/local/lib/python2.7/site-packages/dbr/vista.py", line 194, in mostrar_libro
remove_whilespace_nodes(lista[x].childNodes)
NameError: global name 'remove_whilespace_nodes' is not defined
Please advise with a quick solution
Thanks
Anes