Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I am trying to write to a XML file.

I can write some values but limited. When I add an extra line or value the xml file stop updating and all commands I have after the xml.close(); aren't executed

  File xml = FileSystem.open("/mnt/sda1/Data/data.xml", FILE_WRITE); // open the file
  if(xml){
    Serial.println("XML Opened");
    xml.println("<?xml version=\'1.0\' encoding=\'UTF-8\'?> ");
    xml.println("<sea>");
      xml.println("\t<temperatures>"); //ASCII control codes (TAB)
        xml.print("\t\t<water>");
          xml.print(waterTmp);
        xml.println("</water>");
      xml.println("\t</temperatures>");
    xml.println("</sea>");


    xml.close();
  }
  else{
    Serial.print("XML Error");
  }

For e.g if I add

xml.print("\t\t<air>");
xml.print(airTMP);
xml.println("</air>");

If this lines of code are alone in a sketch everything is good. Another strange thing is if I add the same line twice or more times it can write them to the file.

Do you have any idea how this problem could be solved?

share|improve this question
    
It's a workaround, but have you considered offloading this logic to a python script? Python has excellent XML handling built in (xml.etree.ElementTree) –  anthropomo Jul 19 '14 at 18:14
    
Yes, my solution was giving this job to the php side. –  S.I.Tsaklidis Jul 20 '14 at 20:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.