xml.dom.minidom help!

Paulo Pinto paulo.pinto at cern.ch
Wed Jun 9 11:25:39 EDT 2004


Hi,

I having a problem with xml.dom.minidom parser while
reading some in-house XML configuration files.

The files have a DTD at the begining of the file
specying the XML structure. Some of the attributes
are declared with a default value in case they are
not present in the tags.

When I read the file the parser builds the DOM nodes
with those default values. So when I write the file
I get those default values inside the tags!


For example, the DTD has the following entry

   <!ELEMENT rel (#PCDATA)*>
   <!ATTLIST rel
       name CDATA #REQUIRED
       num CDATA "-1"
   >

So when if I read the tag

<rel name="some name"/>

When I write it back, I get

<rel name="some name" num="-1"/>


I don't want this behaviour. Is it possible to change?


Thanks in advance,
Paulo Pinto



More information about the Python-list mailing list