In a json pulldata response I get a result that looks like this:
<?xml version="1.0" ?>
<Hilltop>
<Agency>Gisborne District Council</Agency>
<Measurement SiteName="Arowhana Repeater">
<DataSource Name="Rainfall" NumItems="1">
<TSType>StdSeries</TSType>
<DataType>SimpleTimeSeries</DataType>
<Interpolation>Histogram</Interpolation>
<ItemInfo ItemNumber="1">
<ItemName>Rainfall</ItemName><ItemFormat>F</ItemFormat><Units>mm</Units><Format>#.###</Format>
</ItemInfo>
</DataSource>
<Data DateFormat="Calendar" NumItems="1">
<E><T>2021-09-06T16:40:00</T><I1>23.2</I1></E>
</Data>
</Measurement>
</Hilltop>
All I want from the data is the rainfall value in this case 23.2
The pulldata works fine but I try to use regex to extract out the rainfall value (also where ' ') can be a valid response from the server
I have tried substr but that has limited success when the response length is inconsistent
I tried to use regex(${hilltop_json},'^[+-]?[0-9]{1,2}(\.[05]{1})?$') against the pulldata json response above but I just get a 'false' as the response
the response is always between the <I1> and </I1> html placeholders (the api is not that clean to present the data that java script stringify and parse seems to recognise unless it is in this html format as per above.)
What would be a more effective way to extract this value as depending on the returned value (amount of rain) ? I wish the survey user to do a specific task differently when the rainfall increases.