What script to use the xml-file?

Moderator: Mattk

Post Reply
User avatar
WS Grave
Expert Boarder
Expert Boarder
Posts: 103
Joined: Fri Oct 30, 2009 3:42 pm
Location: Grave - the Netherlands
Contact:

What script to use the xml-file?

Post by WS Grave »

I'm not used to work with xml, but could anyone tell me how to convert a line in the all-sensors.xml into actual data for me to put on my site?

I guess it's something like this:

Code: Select all

<?php 
$dataUrl = 'http://domainname/all-sensors.xml'; 
$data = simplexml_load_file($dataUrl); 

and than what???

} 
?>
Appreciate any help !
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7877
Joined: Mon Oct 01, 2007 10:51 pm

Re:What script to use the xml-file?

Post by admin »

I would do it the other way round...

Give your html-page to Meteohub as a template and let Meteohub fill in values and loading the resulting HMTL up to your web server.
User avatar
WS Grave
Expert Boarder
Expert Boarder
Posts: 103
Joined: Fri Oct 30, 2009 3:42 pm
Location: Grave - the Netherlands
Contact:

Re:What script to use the xml-file?

Post by WS Grave »

It seems that one minute the data are filled in OK, but the other minute not and I get to see the code instead of data for some.

That's why I was looking for the xml-way to do it.

I would prefer the html-way however :)

PS.
Could this be due to low "Hold time for live data"?
I had it set to 60 seconds, but it should be higher?
skyewright
Platinum Boarder
Platinum Boarder
Posts: 873
Joined: Fri Jan 25, 2008 6:27 pm
Location: Isle of Skye, Scotland

Re:What script to use the xml-file?

Post by skyewright »

WS Grave wrote:It seems that one minute the data are filled in OK, but the other minute not and I get to see the code instead of data for some.
It can be handy to include

[blank_the_unknown]

somewhere near the top of your html file. That tells Meteohub to just leave a blank if it can't provide a substitute for a particular value.
PS.
Could this be due to low "Hold time for live data"?
I had it set to 60 seconds, but it should be higher?
60 seconds is very tight. Just one missed reading for a lot of sensor types? Mine is set to 300, which is I think the default?
User avatar
WS Grave
Expert Boarder
Expert Boarder
Posts: 103
Joined: Fri Oct 30, 2009 3:42 pm
Location: Grave - the Netherlands
Contact:

Re:What script to use the xml-file?

Post by WS Grave »

Thanks for that tip Skyewright.

But I probably found it.
I've set the "Hold time for live data" to the original 300 seconds, and since than all data is filled in OK.

I had it set to 60 seconds, and mostly the UV gave an error, which is because of the 1.5 minute update I guess...
skyewright
Platinum Boarder
Platinum Boarder
Posts: 873
Joined: Fri Jan 25, 2008 6:27 pm
Location: Isle of Skye, Scotland

Re:What script to use the xml-file?

Post by skyewright »

WS Grave wrote:Thanks for that tip Skyewright.
Actually, I forgot to mention that there is also a newer, fancier, technique available too. Maybe you've already spotted it?

With the newer technique you can specify what you want to appear if the value is not available, e.g.

[actual_rain0_rate_mm:-]

would each give either the current actual rain rate, or a dash if actual_rain0_rate_mm wasn't available.
Post Reply