Processing Forum
// The following short XML file called "mammals.xml" is parsed // in the code below. It must be in the project's "data" folder. // <?xml version="1.0" encoding="UTF-8"?> // <positions> // <positionsX time="2013-05-15-18:54:40">69</positionsX> // </positions> XML xml; String mouseLocationsX; String mouseLocationsY; String timestamp; // got it from http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/ void setup() { } void draw() { } void mousePressed() { if (mousePressed == true) { point (mouseX, mouseY); // make points based on mouse location print("mouseX: "); // print mouse X location print(mouseX); print(" "); timestampFunction (); mouseLocationsX = Integer.toString (mouseX); mouseLocationsY = Integer.toString (mouseY); xmlCreate(); } } void timestampFunction () {// time stamp function timestamp = year() +"-" + nf(month(), 2) + "-" + nf(day(), 2) + "-" + nf(hour(), 2) +":" + nf(minute(), 2) + ":" + nf(second(), 2); println(timestamp); } void xmlCreate () { xml = createXML("positions"); // parents XML positions = xml.addChild("positionsX"); // create a child called "position X" positions.setContent(mouseLocationsX); // x mouse location positions.setString("time", timestamp); // create attribute to child saveXML (xml, "positions.xml"); }