I'm having some trouble extrapolating similar SO threads to a larger XML where there are multiple children with different names. For example, here is a subset of a file I'm working with:
<?xml version="1.0" encoding="UTF-8"?>
<SDDXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RulesetFilename file="T24N_2022.bin"/>
<Model Name="Proposed">
...
<Model Name="Standard">
<Proj>
<Name>project0001</Name>
<DevMode>1</DevMode>
<BldgEngyModelVersion>16</BldgEngyModelVersion>
<AnalysisVersion>220070</AnalysisVersion>
<CreateDate>1650049043</CreateDate>
<EnergyUse>
..
<EnergyUse>
<Name>Efficiency Compliance</Name>
<EnduseName>Efficiency Compliance</EnduseName>
<ProposedTDV index="0">270.095</ProposedTDV>
<StandardTDV index="0">99.089</StandardTDV>
...
And I'm trying to the the value of 'ProposedTDV' = 270.095. I've tried BeautifulSoup and ElementTree, but I'm just having trouble finding the syntax to specify the name of a child. Ie since I can't use a search string like:
Model/Proj/EnergyUse/ProposedTDV
I'm trying to find something more like:
Model[Name="Standard"]/Proj/EnergyUse[Name='Efficiency Compliance']/ProposedTDV
or similar that I could use with BeauftifulSoup (or any other XML parser).
For example, I've tried things like
from bs4 import BeautifulSoup
result = open(--xml_file_path--,'r')
contents = result.read()
soup = BeautifulSoup(contents,'xml')
test = soup.Model[Name="Proposed"].Proj.EnergyUse[Name='Efficiency Compliance'].findAll("ProposedTDV")
But I know that the syntax there is wrong.