xml parsing by sitename

Hi, there:

I’m trying to retrieve the air quality data from local government’s website opendata2.epa.gov.tw/AQX.xml. Since I need only the data from a specific site, what I have to do is to search the site, extract all the site data, and parse specific index.
Based on the python documentation docs.python.org/3.5/library/xml … ttree.html
I came to some code like this:

import xml.etree.ElementTree as ET

def valueChange(channel, sampleIndex, val, prev):

	tree = ET.parse('http://opendata2.epa.gov.tw/AQX.xml')
	if tree.find('siteName').text equl '中山'
		siteRoot = tree.getroot()

	PM2_5 = root.find('PM2.5').text
	op('webValue').par.value0 = int(PM2_5)

	return

Unfortunately the xml.etree.ElementTree module cause problem and the chinese character cannot be properly handled by TD’s DAT.

Is there anyone has any ideas?

Many thanks in advance!

 adenovirux

This is purely a python / utf-8 issue. After a quick search I saw some threads from people who had similar issues on the Stackoverflow site. I think you’ll find your answer there in the big python community sooner than here on the touchdesigner forum. Maybe you need to convert those characters first to another format.