1

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?

2
  • 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) Commented Jul 19, 2014 at 18:14
  • Yes, my solution was giving this job to the php side. Commented Jul 20, 2014 at 20:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.