[program-l] Python XML accessing data in sub elements

  • From: <reynoldsdavid46@xxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Mon, 7 Nov 2022 16:28:49 -0000

Hi,

Here is my code so far:

<code begins>

import xml.etree.ElementTree as ET

mytree=ET.parse("away in a manger.xml")

myroot=mytree.getroot()

p=0

for note in myroot.iter("pitch"):

<code ends>

This iterates through all the pitch elements in the file correctly, but I
need to access sub elements of pitch, i.e. extract the data from those sub
elements.

Any help much appreciated.

 

David.?

Other related posts: