[XML-SIG] Removing insignificant whitespace

Brian Quinlan brian at sweetapp.com
Tue Aug 31 18:49:50 CEST 2004

I'm trying to remove the whitespace-only text nodes in my XML DOM. I've 
tried two approaches:

1. StripXml - generates a an exception:

   File "mac.py", line 25, in __init__
"/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/__init__.py", line 
153, in StripXml
     snit = owner_doc.createNodeIterator(startNode, NodeFilter.SHOW_TEXT,
AttributeError: Document instance has no attribute 'createNodeIterator'

2. setFeature('whitespace_in_element_content', False) seems to do

My code is here:

from xml import xpath, dom
from xml.dom.ext import StripXml
from xml.dom.xmlbuilder import DOMInputSource, DOMBuilder
from optparse import OptionParser
from pprint import pprint
import os

b = DOMBuilder()
b.setFeature('whitespace_in_element_content', False)
self.document = b.parse(...)

My XML does not include a DTD or any declarations regarding whitespace. 
  Can anyone offer any advice?


More information about the XML-SIG mailing list