Sunday, November 10, 2013

Mail body parsing

Now that I can receive emails, the next step will be to parse the mail body.
Although I have no Python experience it seems to be well supported by the Yun, so I will try that road...

The mail body should be an xml document. For now, I will just try to parse a mail body that contains:

<temp> 22.3 </temp>

I will not worry about error handling, etc.... that is an important aspect, but for later.

I am going to use ElementTree for parsing. When I tried to build a tree from my body string as follows:

tree = ET.ElementTree(ET.fromstring(body))

I got the error:

ImportError: No module named expat; use SimpleXMLTreeBuilder instead

I solved this by:

opkg update
opkg install python-expat

No comments:

Post a Comment