Print all text

Report a typo

You are given an XML document which consists of a root element and its several child elements. Each of these child elements stores some text inside. Write a program that iterates over the child elements and prints text that they contain.

The XML document is given in input in one string.

Sample Input 1:

<root><elem1>I am elem1</elem1><elem2>I am elem2</elem2><elem3>I am elem3</elem3></root>

Sample Output 1:

I am elem1
I am elem2
I am elem3
Write a program in Python 3
from lxml import etree
___

Create a free account to access the full topic