I have the following XML that I need to print out the content of members, I am trying to do this using elementree but I cannot figure out how to do this, below is the xml:
<response status="success"><result><entry name="TEST-ADDRESS-GROUP"> <static> <member>TEST_1</member> <member>TEST_2</member> </static> </entry></result></response>
CodePudding user response:
Try this one :
import xml.etree.ElementTree as ET
xml_data = '''<response status="success"><result><entry name="TEST-ADDRESS-GROUP">
<static>
<member>TEST_1</member>
<member>TEST_2</member>
</static> </entry></result></response>
'''
tree = ET.fromstring(xml_data)
member_elements = tree.findall('.//member')
text_in_member_elements = [element.text for element in member_elements]