The Sonic Landscape

Parsing XML Data directly into Max/Msp

Posted on | October 30, 2010 | No Comments

(This post has since been updated, click HERE to view the updated max/msp patch)

Had quite a busy and stressful week, working very long hours each day trying to parse XML data from Pachube directly into Max/Msp.

I had some feedback from my tutors last week and came to the decision of trying to make my Pachube Sinewave Project (see earlier blog posts), as a standalone interface (without the need to use Processing to get the Pachube data). This standalone option is a temporary measure until i start building the gallery installation itself (planned early 2011).

After working approximately 10-12 hours a day, i have FINALLY got my (Max/Msp) standalone app working correctly. I literally had to deconstuct my max patch and rebuild it from the ground up, testing out various techniques of parsing the XML data correctly.

Its been a major task having to rethink the project, whilst also learning how to correctly parse the XML data from Pachube for the data feeds I required.

Firstly i tried this method: (my api key has been removed for security purposes)

Example 1. (shown below)

________________________

Originally, i used the jitter objects:   jit.uldl, jit.textfile, jit.str tosymbol, combined with detox (xml parser), but had major problems using detox. I’m not sure if the problem was caused by authenticating my pachube api key, but no matter what i did, the detox max object would intermittently crash on a regular basis. The crashes may have been caused by the XML structure not being ‘standard’ XML format.

I then had to specify ‘which line’ from the XML file, contained the data i needed to extract. This was quite a long process, having to look at each XML file for the 13 data feeds, and manually calculating the line number for use.

Due to the problems of detox crashing regularly (although it may not have been a problem with detox itself, but more likely the XML structure of the data i was trying to extract), I then looked at other max objects which could similarly parse the data.

After days and days of experimenting (very long hours!) i used a different technique (as shown below), whereby i specified the xml tag <> in conjunction with specifying the line number of the XML data i needed.

_______________________

The above example is not ideal, but its a quick workaround to get the data i needed. I was previously unable to get the data using correct XML tags, (such as  <value></value>), so this technique at least got the data i needed, (without the use of the detox object).

I added lots of other changes for my Max/Msp patch, notably using the patcher object with inlets and outlets, and then duplicating these to save time from manually re-creating each internal patch.  I also adapted the interface to function as a standalone app (using a ‘textedit’ object to allow user input of a Pachube API key). Also allowed the user to switch on/off data feeds by clicking the corresponding LED on the map.

This morning, i recreated each internal patcher (for each data feed) and removed the detox objects, using the newer examples i had successfully tested and so far so good….i can run the app for 10-20 minutes without it crashing at all.

Shown below is the newly created ‘standalone app’ which requires the user to input a valid Pachube API key (an api key is given once registered with pachube). I will upload a working version of this sometime in the future, but hope to further improve on the patch over the next few weeks.

Will update soon, when more progress has been made…

Click image below (for larger view)

Comments

Leave a Reply





*

  • Pages

  • Admin

  • Archives