[lxml-dev] complex node

Stefan Behnel stefan_ml at behnel.de
Tue Jul 14 21:16:55 CEST 2009


Hi,

Jonas wrote:
> 2009/7/13 Stefan Behnel wrote:
>> Jonas wrote:
>>> I'm trying to parsing a xml file (in python) to convert it to
>>> dictionaries and then to JSON.
>>>
>>> This is the file:
>>> http://unicode.org/cldr/data/common/main/es.xml
>>> and I've got all nodes except dates', which is enought complex.
>>>
>>> Any idea to get it? because I'm very tired of try it.
>> What's your question?
>>
>> - how to find the 'dates' element in a parsed tree?
>> - how to traverse the subtree of the 'dates' element?
>> - how to extract the data from the parsed tree?
>> - how to extract the data using iterparse()?
>> - how to map the data to a dictionary?
>> - how to map the data to a dictionary while parsing?
>> - how to map the data to a recursive structure of dictionaries?
>
> This is my main problem. But
> checking i.e. if each element has attributes to manage it

What about providing some more background and detail so that we can
understand the problem you are trying to solve? So far, I have no idea
about the target data structure that you want to construct, or what
information in the XML document you consider important.

This might be worth reading:

http://www.catb.org/~esr/faqs/smart-questions.html

Stefan



More information about the lxml-dev mailing list