[lxml] Re: Streaming read/write

2024-01-29 Thread Charlie Clark
On 21 Jan 2024, at 12:42, Stefan Behnel wrote: Hi Stefan, > If you want to avoid creating element objects all together, maybe even don't > need a full (sub-)tree structure to get all relevant information, I suggest > you try the low-level SAX interface. > > https://lxml.de/parsing.html#the-targ

[lxml] Re: Streaming read/write

2024-01-21 Thread Stefan Behnel
Charlie Clark schrieb am 19.01.24 um 15:00: On 18 Jan 2024, at 18:10, Charlie Clark wrote: Apart from the fact that this currently doesn't work, I imagine that both Elements and their children would happily be passed to the write, which could lead to an almighty mess. Getting this to work pro

[lxml] Re: Streaming read/write

2024-01-19 Thread Charlie Clark
On 18 Jan 2024, at 18:10, Charlie Clark wrote: > Apart from the fact that this currently doesn't work, I imagine that both > Elements and their children would happily be passed to the write, which could > lead to an almighty mess. Getting this to work properly, possibly rewritten > for async to

[lxml] Re: Streaming read/write

2024-01-18 Thread Charlie Clark
On 18 Jan 2024, at 15:48, Stefan Behnel wrote: Hi Stefan, You might want to look into the more general XMLPullParser, but yes, both that and iterparse() generate a full XML tree in the back. The idea is that you actively delete parts of it when you're done with them, but you gain easy tree na

[lxml] Re: Streaming read/write

2024-01-18 Thread Stefan Behnel
Hi Charlie, Charlie Clark schrieb am 18.01.24 um 12:13: I was recently wondering about the best way to edit XML documents using both a streaming reader and writer. I'm sure this is possible using iterparse and xmlfile but I seem to remember that iterparse produces the full tree so that parent el