[lxml-dev] Efficient methods to build a tree out of HTML structure?

Stefan Behnel stefan_ml at behnel.de
Fri May 16 12:46:38 CEST 2008


Hi,

Dennis Benzinger wrote:
> Am 16.05.2008 11:56, Stefan Behnel schrieb:
>> Viksit Gaur wrote:
>>> The problem I face was a method to assign a unique ID to each
>>> element on the page.
>>>
>>> Lets say I construct an iterwalk object. But, during this phase, I would
>>> like to not only build the tree, but also add some of my own information
>>> to each node (such as a unique ID to each element).
>> I still don't understand what you mean with "build the tree". You can't
>> construct a tree and run iterwalk at the same time. iterparse() will do that
>> in case you are parsing.
>> [...]
> 
> I think he is talking about his own tree. The tree he is building to
> visualize the structure of the XML data.

Ok, but if it's that, then I don't understand why iterating over the tree and
adding an id attribute to each node won't do the job.

Stefan



More information about the lxml-dev mailing list