Is there an equivalent for xml.etree.ElementTree module?

Viewed 165

I'm parsing a bunch of XML elements just fine, using the code below.

import pandas as pd
import datetime
import requests
import pandas_gbq
import xml.etree.ElementTree
REQUEST_URL = 'https://www.corporate-site/report-api/?obj_device=47116&Yesterday'
response = requests.get(REQUEST_URL, auth=(login, password))
xml_data = response.text.encode('utf-8', 'ignore') 

root = xml.etree.ElementTree.fromstring(xml_data)

desc = root.get("Description")

The code above works perfectly fine in my client-side Python 3.6 setup. I'm having a big problem moving this into a Google Cloud Function, because apparently Google doesn't recognize this xml.etree.ElementTree module. Has anyone here used Google Cloud Functions? If so, is there a way to get the remote, server-side, environment setup to match a local environment? Or, is there an equivalent of the xml.etree.ElementTree module, which does a good job of parsing XML syntax? Thanks to all.

1 Answers

You can check in the System Packages list what are the current supported packages in the Python3 runtime, for Cloud Functions.

Doing a quick search, seems that the only supported module related to XML is libxml2. You can check the documentation of this library here. As well can check how this library's Python binding works in this examples.

As well, if this library it's not enough for the usage you want to make out of your Cloud Function, you can issue a Feature Request in the issue tracker to ask for the implementation of your requested libraries. This is the direct link to create a new Feature Request.

Related