Skip to content

Instantly share code, notes, and snippets.

@psd
Forked from 9600/text.xml
Last active March 14, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psd/a881cec669b1741301e5a6dabea6f783 to your computer and use it in GitHub Desktop.
Save psd/a881cec669b1741301e5a6dabea6f783 to your computer and use it in GitHub Desktop.
22.3
°C
not found
/(1) EBusRoot/(3) Zusatzmodul/(4) CIRCUIT 1/(119) /(3) 00:01
#!/usr/bin/env python3
from xml.etree import ElementTree as ET
ns = {
'env': "http://schemas.xmlsoap.org/soap/envelope/",
'ns': "http://ws01.lom.ch/soap/",
}
tree = ET.parse('test.xml')
value = tree.find('.//value', ns)
print(value.text)
unit = tree.find('.//unit', ns)
print(unit.text)
missing = tree.find('.//missing', ns)
if missing is None:
print("not found")
oid = tree.find('./env:Body/ns:getDpResponse/ref/oid', ns)
print(oid.text)
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://ws01.lom.ch/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns:getDpResponse>
<ref>
<oid>/(1) EBusRoot/(3) Zusatzmodul/(4) CIRCUIT 1/(119) /(3) 00:01</oid>
<prop>-r--</prop>
</ref>
<dpCfg>
<index>3</index>
<name>00:01</name>
<prop>-r--</prop>
<desc>Scalar Var</desc>
<value>22.3</value>
<unit>°C</unit>
<type>13</type>
<step>0.1</step>
<minValue>0.0</minValue>
<maxValue>50.0</maxValue>
</dpCfg>
</ns:getDpResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment