Read data from xml file


Hi, I receive an xml file from a webhook that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
active_power_TOT="68.41" /></root>

I want to read that 68.41 inside active_power_TOT. How can I do it?


That’s normal string parsing.
Scan for TOT=" and take the portion up to ".

I’d use strstr() for finding the first part and then again strstr() or strpbrk().

Or, if you want the numeric value, locate the beginning (as above) and then take the string after TOT=" into atof() or strtod()

Or you use the way shown in the docs :wink:

REST API arguments - is there a better way?

Hi, I partially solved the problem. I’m now able to read inside energy data using the particle docs example, but i can’t read that specific value inside active_power_TOT.


Hi, i’m trying to get data from an xml attribute. I’m using the following example:
Using this I was able to read part of the xml file, but i can’t isolate the data from that specific attribute. How can I do it?


Did you look at the functions I provided above?
These are all you need to solve the problem.