A
Ajay
hi!
i am trying to remove all whitespace elements out of a document.
my code is below
def stripWhiteSpaces(doc):
whiteSpaces = xpath.Evaluate("//text()", doc.documentElement)
counter=0
while(counter< len(whiteSpaces)):
str = whiteSpaces[counter].nodeValue
string.strip(str)
if len(str) == 0:
whiteSpaces[counter].parentNode.removeChild(whiteSpaces[counter])
counter += 1
return doc
however this isn't working. when i print out all the elements in the
document, i still get the whitespace text elements.
what am i doing wrong?
thanks
cheers
i am trying to remove all whitespace elements out of a document.
my code is below
def stripWhiteSpaces(doc):
whiteSpaces = xpath.Evaluate("//text()", doc.documentElement)
counter=0
while(counter< len(whiteSpaces)):
str = whiteSpaces[counter].nodeValue
string.strip(str)
if len(str) == 0:
whiteSpaces[counter].parentNode.removeChild(whiteSpaces[counter])
counter += 1
return doc
however this isn't working. when i print out all the elements in the
document, i still get the whitespace text elements.
what am i doing wrong?
thanks
cheers