0

it seemed too easy. I stored an xml file on a sdcard connected to my esp32. I use the SD.open() function to access the files stored on the sdcard. For parsing the xml file I downloaded the tinyxml2 library and tried to use the xmlDocument.LoadFile() function.

The problem is that the xmlDocument.LoadFile function is using a std::File pointer. The SD.open() function return an fs::File pointer.

The resulting error message in my ArduinoIDE is:

No matching function for call to tinyxml2::XMLDocument::LoadFile(fs::File*).

Does anybody has an idea how to convert the fs::File* into std::File*?

Thank you very much!

tinyxml2 lib:tinyxml2 lib

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • Maybe, could be easier if you read using only SD.open() closing after read and instead of use the same descriptor (fs::File), create another descriptor (std::File) and write avoiding this problem. – JTejedor Sep 27 '20 at 12:51
  • 1
    Could you use `SD` to load the file into memory and then [tinyxml2::XMLDocument:Parse](https://leethomason.github.io/tinyxml2/classtinyxml2_1_1_x_m_l_document.html#af2b616169e6517182f6725f2498e9a01) to process the `XML` from there? – Galik Sep 27 '20 at 13:05
  • why xnl? can't you use JSON? – Juraj Sep 27 '20 at 17:36
  • As @Galik mentioned I'll try to use the function Parse(const char*) to solve my problem. – user2110946 Sep 27 '20 at 18:25
  • @Juraj , you are right. First tinyXML2 isn't the best way to parse xml files on an esp32. SAX parser seem to be not that RAM hungry. JSON might be a better solution at all. But before changing all from xml to json, I will try to solve the problem. This is not an XML problem but a general problem i might have with other libraries. Not easy if you are not familiar with c++ (or whatever arduino ide is offering) – user2110946 Sep 27 '20 at 18:31
  • I think it shouldn't be hard to write a std:File wrapper for fs::File – Juraj Sep 27 '20 at 18:47
  • I ve never done this before. It will :) – user2110946 Sep 27 '20 at 18:56

1 Answers1

0

Thank you so much.

as @Galik mentioned, his hint was the key for me. But in the long run @Juraj suggestion to use json the better way.