bonjour,
j'ai erreur php :
l'erreur ne se produit pas toujours ,parfois sa fonctionne bienFatal error: Call to a member function getElementsByTagName () on a non-object in /weather /classes/BxWeatherModule.php on line 37
voiçi la fonction:
le fichier xml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 function serviceWeatherIndexPage(){ include("geoipcity.inc"); include("geoipregionvars.php"); $ip = $_SERVER['REMOTE_ADDR']; $weather_feed = ""; $pathr= BX_DOL_URL_ROOT; $gi = geoip_open("../GeoLiteCity.dat",GEOIP_STANDARD); $record = geoip_record_by_addr($gi,$ip); geoip_close($gi); $city = $record->city; if ($city == "") $city = "Sydney"; $url_post = "http://where.yahooapis.com/v1/places.q('".urlencode($city)."')?appid=foOF4CzV34EFIIW4gz1lx0Ze1em._w1An3QyivRalpXCK9sIXT5de810JWold3ApkdMdCrc-"; $weather_feed = file_get_contents($url_post); $objDOM = new DOMDocument(); $objDOM->loadXML($weather_feed); $woeid = $objDOM->getElementsByTagName("place")->item(0)->getElementsByTagName("woeid")->item(0)->nodeValue; }
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <places xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:start="0" yahoo:count="1" yahoo:total="38"> <script>...</script> <place yahoo:uri="http://where.yahooapis.com/v1/place/615702" xml:lang="fr-FR"> <woeid>615702</woeid> <placeTypeName code="7">Ville</placeTypeName> <name>Paris</name> <country type="Pays" code="FR" woeid="23424819">France</country> <admin1 type="Région" code="" woeid="7153319">Île-de-France</admin1> <admin2 type="Département" code="FR-75" woeid="12597155">Paris</admin2> <admin3/> <locality1 type="Ville" woeid="615702">Paris</locality1> <locality2/> <postal/> <centroid> <latitude>48.856930</latitude> <longitude>2.341200</longitude> </centroid> <boundingBox> <southWest> <latitude>48.658291</latitude> <longitude>2.086790</longitude> </southWest> <northEast> <latitude>49.046940</latitude> <longitude>2.637910</longitude> </northEast> </boundingBox> <areaRank>3</areaRank> <popRank>13</popRank> </place> </places>







Répondre avec citation
Partager