save xml to external harddrive
in
Programming Questions
•
1 year ago
Hello,
I have a simple piece of code (see below). I don't want to save my xml file to the sketch folder, but to an external hard drive.
I guess all that is important to change is the following line of code. This is actually the destination I want to save the file to.
- xmlIO.saveElement(xmlPulses, "/Volumes/Public/Test/test.xml");
Running the sketch like this it saves the xml inside my data folder and creates new subfolders calledVolumes/Public/Test and inside the "Test" folder it saves the xml.
How do I get it to not create new folders but take the given destination and save it there?
- import proxml.*;
- int posX;
- int posY;
- XMLInOut xmlIO;
- proxml.XMLElement xmlPulses;
- void setup() {
- size(400, 400);
- xmlIO = new XMLInOut(this);
- try {
- xmlIO.loadElement("test.xml");
- }
- catch (Exception e) {
- xmlEvent(new proxml.XMLElement("pulses"));
- }
- }
- void xmlEvent(proxml.XMLElement element) {
- xmlPulses = element;
- }
- void draw() {
- background(0);
- posX = mouseX;
- posY = mouseY;
- }
- void mousePressed() {
- saveData();
- }
- void saveData() {
- proxml.XMLElement newPulse = new proxml.XMLElement("datensatz");
- xmlPulses.addChild(newPulse);
- proxml.XMLElement value1 = new proxml.XMLElement("value1");
- proxml.XMLElement value2 = new proxml.XMLElement("value2");
- value1.addAttribute("value1", posX);
- value2.addAttribute("value2", posY);
- newPulse.addChild(value1);
- newPulse.addChild(value2);
- xmlIO.saveElement(xmlPulses, "/Volumes/Public/Test/test.xml");
- }
1