I want to read IntakeFanSpeedMax, IntakeFanSpeedMin tag value and update using python in below xml, tried many tutorials but not able to read and update it. Please help me on this, Thanks in advance.
<?xml version="1.0"?>
<RobotManager Checksum="CCA4FBB2C307EBE537BDCEAFB340F5F22ABE178951B0F7FDDFBDC8939D0A3CAC">
<Setup>
<AddressHostName>192.168.2.1</AddressHostName>
<PowerStateMonitor>
<PowerStateMonitor1>
<CommPort>2</CommPort>
</PowerStateMonitor1>
<PowerStateMonitor2>
<Pmu>
<!-- in seconds (minimum: 90; maximum: 150) -->
<AcNotPresentShutdownTime>120</AcNotPresentShutdownTime>
<!-- in degrees Celsius (minimum: 0; maximum: 100) -->
<BatteryTemperatureDifferential>6</BatteryTemperatureDifferential>
<!-- in RPMs (minimum: 3000; maximum: 5000) -->
<IntakeFanSpeedMax>4000</IntakeFanSpeedMax>
<!-- in RPMs (minimum: 750; maximum: 1300) -->
<IntakeFanSpeedMin>1000</IntakeFanSpeedMin>
</Pmu>
</RobotManager>
my code:
import xml.etree.ElementTree as ET
fileXml = "C://Users//...//Documents//RobotManagerSettings.xml"
tree = ET.parse(fileXml)
root = tree.getroot()
IntakeFanSpeedMax = root.find('IntakeFanSpeedMax').text
print(IntakeFanSpeedMax)
getting below error:
"C:\Users\Sagar Hosamath\AppData\Local\Programs\Python\Python39\python.exe" "C:/Users/Sagar Hosamath/PycharmProjects/Coord/venv/Scripts/xmlPath.py"
Traceback (most recent call last):
File "C:\Users\Sagar Hosamath\PycharmProjects\Coord\venv\Scripts\xmlPath.py", line 6, in <module>
IntakeFanSpeedMax = root.find('IntakeFanSpeedMax').text
AttributeError: 'NoneType' object has no attribute 'text'
Process finished with exit code 1