<elem1>
<elem2/>
<elem2 id="1234567"/>20,000 Leagues Under the Sea</elem1>
I've been trying to insert strings from list x, if the id provided matches with a list item using lxml. The problem being, I can't seem to find a way to do make it go right before the end of parent tag </elem1>.
Example string:
<elem3><elem4>book, item</elem4></elem3>
Desired output:
<elem1>
<elem2/>
<elem2 id="1234567"/>20,000 Leagues Under the Sea<elem3><elem4>book, item</elem4></elem3></elem1>
.tail function can do the thing I want, but on the opposite side of the tag, not inside it. Simply appending string to .text of the element technically works, but it can't display it due to, I imagine, <elem2/> tags at the beginning in some cases, and after such case it usually stops working in subsequent iterations of a loop.