Reputation: 157
Let's say I have the following content -
<test> This is some text </test>
<test> This is other text </test>
Now I want to extract the content from both tags, but be able to refer to them as tag-1 and tag-2 so that I can work with them separately. How do I do that?
Upvotes: 0
Views: 344
Reputation: 2472
Use root.findall("test"). This will return a list of elements -- use indices rather than different tag names.
root.findall("test")[0].text --> "This is some text"
root.findall("test")[1].text --> "This is other text"
Upvotes: 1