xml question
Ivan Herman
ivan at ivan-herman.net
Sat Aug 14 09:27:08 EDT 2004
I think this is a bug in your python call. AFAIK, 'string.strip(str)'
*returns a copy of a string with stripped whitespace*. Ie, it does not
affect the original string, in this case the nodeValue...
Ivan
Ajay wrote:
> 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
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
More information about the Python-list
mailing list