I have a device that is outputting XML data via a serial line every few seconds. I need to interface an Arduino with it to parse the data and then do some other stuff with the values it gets. This is a standalone portable unit that only exports XML and I don't want to connect a PC or something else to handle the data. I'd like the Arduino to do the parsing if it's possible. The datastream looks like this:
What is the preferred method for parsing the two number string out of the above text and once I do that, is there a good method for converting 1.01388e2 to 101.388.
I’d like the Arduino to do the parsing if it’s possible.
Sure, it’s possible.
The datastream looks like this
More important than the data stream is how the data is collected on the Arduino. Are you using a char array (preferred) or a String to collect the data?
If you are using the char array method, strtok() can be used to locate tokens, such as < and >. The data betwen some tokens defines the type of value (celltemp, for instance). The data between other tokens defines the actual value string (5.13581e1). The atof() function can be used to convert a float-like string to an actual float value. It will handle the exponential notation, I think. If not, there are other methods for converting the string to a value.