Importing and Web Services

Hi Guys,

I’m new to Ignition. I noticed when running the code directly inside the script console. My script is working fine. Below is my sample script:

import xml.etree.cElementTree as ET

#Build the XML and return element for further processing
InSite = ET.Element(’__InSite’)

print str(InSite)

In this sample snippet this works fine. However when I incorporate this code inside the Web Dev Module (WebService) my print str(InSite) is null. I think the import xml.etree.cElementTree as ET is culprit here. Is importing not allowed in Web Dev Module? Any suggestions?


Ian, 2 things… you can check the gateway console for any errors related to the WebDev module

Additionally you var you are trying to print is a reference to an ET object, not a string. You should use the ET method to convert before you return it.

xml = ET.tostring(ET_xml_object)
return {'html': xml}