newbie: minidom

Paul Watson pwatson at redlinepy.com
Sat Nov 11 11:00:20 EST 2006


Fredrik Lundh wrote:
> Danny Scalenotti wrote:
> 
>> I'm not able to get out of this .......
>>
>> from  xml.dom.minidom import getDOMImplementation
>>
>> impl = getDOMImplementation()  // default UTF-8
>> doc = impl.createDocument(None, "test",None)
>> root = doc.documentElement
>> root.setAttribute('myattrib', '5')
>>
>> print root.toxml()
>>
>>
>> I obtain
>>
>> <test myattrib="5"/>
>>
>> why not this?
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <test myattrib="5"/>
> 
> 
> why?  the documents are equivalent, and any XML application that 
> requires an explicit UTF-8 encoding declaration is broken.
> 
> </F>

Explicit is better than implicit.



More information about the Python-list mailing list