Quantcast
Channel: ThingSpeak IoT Community - All Forums
Viewing all articles
Browse latest Browse all 1833

mchampio on How to deserialise thingspeak feeds xml data with PHP

$
0
0


Thank you so much jvasudev, that is exactly what I was looking for.Smile

I added the loop at the bottom, so noobs like me could see how to use the data in the field

<?php
$url = "https://api.thingspeak.com/channels/203731/feeds.xml?results=500";
$xml = simplexml_load_file($url);
$description = (string) $xml->description;
print_r($description);
$field1 = $xml->xpath('//feed/field1'); // get all <field1/> whose parent is <feed/>
print_r($field1);
$field2 = $xml->xpath('//feed/field2'); //gets all <field2/> whose parent is <feed/>
print_r($field2);
foreach ($field2 as $onefield2) {
  echo $onefield2;
  echo '<br/>';
}
?>


Viewing all articles
Browse latest Browse all 1833

Trending Articles