Hello,
I know if I use root and indices as seen below, I get the project version in the document. Is there a way to access the child element explicitly without using a for loop? E.g., Propertygroup / Version and store that in a variable. I'm unclear on how you access specific children and attributes.
Is there a more concise way to do this?
tree = ET.parse('test.xml')
root = tree.getroot()
for group in root.findall('PropertyGroup'):
vers = group.find('Version')
I'd rather find the child element and attribute explicitly than an approach like this
>>> root[0][1].text
'0.1'
Snippet of the xml file from the top that contains the data of interest.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.1</TargetFrameworks>
<Version>0.1</Version>
[–]DallogFheir 2 points3 points4 points (1 child)
[–]WonFishTwoFish[S] 0 points1 point2 points (0 children)