Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
parsing xml
#2
# xml_as_string = """ Your xml goes here"""
# 
# root = ET.fromstring(xml_as_string)

root = et.fromstring(data)
for el in root.findall(".//Codec[@Name='PCMU']"):
    if el.attrib['Enabled'].lower().strip() == "true":
        el.attrib['Enabled'] = "False"
    print('Found element: {}'.format(el.attrib))

s = ET.tostring(root, encoding='utf8', method='xml')

print(s.decode('utf-8'))
Reply


Messages In This Thread
parsing xml - by josesalazmit - Mar-05-2019, 12:23 AM
RE: parsing xml - by scidam - Mar-05-2019, 02:20 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020