Case-insensitive XML Parsing

Martin v. Löwis loewis at informatik.hu-berlin.de
Mon Aug 5 15:06:47 CEST 2002


sandeep at octetsoft.com (C. R. Sandeep) writes:

>      I am using the xml.dom.minidom module to do some XML parsing. Is
> there any way I can set an option to do case-insensitive parsing? 

Not built-in, no. You could do the following things:

- lower-case the entire input before parsing;
- if you know the complete list of tags in advance:
  replace all misspellings of these tags before parsing.

Another option, if you have PyXML, is to use sgmlop. sgmlop's
SGMLParser is case-insensitive. You need to create an sgmlop SAX
driver (i.e. "xml.sax.drivers2.drv_sgmlop"), and pass this to
minidom.parse.

Notice that the parser will then operate in SGML mode, which may or
may not work for your input.

Regards,
Martin




More information about the Python-list mailing list