It's probably a little late on this thread to be useful to you, but I'll
respond in case this helps anyone else.

Personally, I'd probably switch to JSON if we didn't have a historical
reliance on XML. The JSON structure if effectively identical to that of
XML: they are both flexible, hierarchical data structures. As others have
mentioned, JSON has built in typing, support for arrays, and is more
compact than xml.

If you must stick with XML:
My experience with minidom left me underwhelmed. It's slow.
cElement tree and lxml are quite comparable in terms of speed. For certain
types of activity (parsing, specifically), cElementTree is actually faster
because of the way it handles the relationships of the python objects to
the C++ objects. Lxml builds out a more complex tree that allows you to
parse the xml structure once it's in memory, in ways you cannot in
cElementTree: get an element's parent, for instance. Also, cElement tree
does NOT preserve comments, so it's not a good working format.

The nice thing about lxml, cElementTree and ElementTree, for that matter,
is that they all share the same interface, so if you abstract your calls
through an intermediary, you can easily switch between the three libraries.
Something like this works well:

try:
import lxml.etree as ET
except:
print 'lxml NOT FOUND. Attempting to load cElementTree.'
try:
from xml.etree import cElementTree as ET
except:
print 'cElementTree NOT FOUND. Attempting to load etree.'
try:
from xml.etree import ElementTree as ET
except:
print 'NO XML MODULE FOUND'

There is quite a lot out there on the web if you care to read more about
specific differences between lxml and cElementTree.

-Judah


On Wed, Sep 19, 2012 at 8:13 PM, DayDreaner <[email protected]>wrote:

> Ya, lxml is very fast.
>
> One Query regarding JSON and XML
>
> Personally, i feel xml provides a nice structure, whereas Json is just a
> dictionary(like pickling).
> What about large data and what if I want to edit the serialized file
> manually(for any wiered reason) and don't want to generate the file
> again(as it is huge).
>
> Thanks
>
> ------
> Day Dreamer
> www.daydreamer3d.weebly.com
>
>
> On Friday, August 24, 2012 6:33:34 PM UTC+5:30, 5inch wrote:
>>
>> Hi Folks,
>>
>> has anyone of you experience with
>> Python´s *xml.dom.minidom* and Maya.
>>
>> I want to export some Maya Attributes (Int,String,Float)
>> via Python in a XML-File.
>> I didn´t find any good howTo/Tutorial on the Web which explains me all
>> the syntax in a
>> Dummie-fashion-way.
>>
>> Thanks for any Links/help,
>>
>> Cheers, 5inch
>>
>  --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to