[lxml-dev] using xpath to grab and *modify* a sub-element?

Hi All, I am new to lxml, but so far it seems that xpath functions/methods return *copies* of a SubElement, and thus any modifications I make to the returned element does not affect the master element. This is quite fine for retrieving data, but what if I want to use xpath to find SubElements, that I then want to modify in some way, so that my changes are reflected in the master Element? Any short code snippet or link to an example would be appreciated. I've been searching but haven't found any yet. Thanks and Regards, -Daniel Robbins

On Thu, 29 Apr 2010 11:16:55 -0600 Daniel Robbins <drobbins@funtoo.org> wrote:
I would expect them to return references to the Elements they find. Not sure about attribute values (i.e. xpaths ending in @foo), that would require some kind of wrapper, but if your xpath returns Elements I'm sure they're references, not copies. So you can modify in place. Cheers -Terry

On Thu, 29 Apr 2010 11:16:55 -0600 Daniel Robbins <drobbins@funtoo.org> wrote:
I would expect them to return references to the Elements they find. Not sure about attribute values (i.e. xpaths ending in @foo), that would require some kind of wrapper, but if your xpath returns Elements I'm sure they're references, not copies. So you can modify in place. Cheers -Terry
participants (2)
-
Daniel Robbins
-
Terry Brown