Skip to content

Instantly share code, notes, and snippets.

@ckarrie
Last active August 29, 2015 14:05
Show Gist options
  • Save ckarrie/775ab758b4d7f1a95a7c to your computer and use it in GitHub Desktop.
Save ckarrie/775ab758b4d7f1a95a7c to your computer and use it in GitHub Desktop.
from xml.dom.minidom import parse
import urllib
IP = "192.168.178.45"
XML_FILE = "status.xml"
DI1_ELEMENT = "DigitalInput1"
OPEN = "OPEN"
CLOSED = "CLOSED"
xmlpath = "http://" + IP + "/" + XML_FILE
try:
xml = urllib.urlopen(xmlpath)
dom = parse(xml)
except Exeption as e:
print(e)
di = dom.getElementsByTagName(DI1_ELEMENT)[0]
v = di.firstChild.nodeValue
if v == CLOSED:
print "DI1 Closed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment