php xml Warning : Attempt to read property
Bonjour
j'ai un problème de php lorsque j'utilise du xml
voici mon code
Code:
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
| <?php
if (isset($_GET['namesc'])) {
$matching = $_GET['namesc'];
} else {
$matching = "-NoName-";
}
$url = "monXml";
$xml = simplexml_load_file($url);
$perf_count = $xml->performer-> count();
for ($i=0; $i<=$perf_count; $i++) {
$matchScreen[$i] = $xml->performer[$i] -> screenname[0]; // ID du performer
$screenup = $matchScreen[$i];
if ($matchScreen[$i] = $matching) {
$j = $i;
$screenup = $matchScreen[$i];
} else {
$screenup = "-NoName-";
}
}
print_r($screenup); |
le xml :
Code:
1 2 3 4 5
| <performer>
<id>1825380</id>
<screenname>Yazmin</screenname>
</performer> |
le souci est là à mon avis
$matchScreen[$i] = $xml->performer[$i] -> screenname[0];
ça me met :
Warning
: Attempt to read property "screenname" on null in
/htdocs/search/index.php
on line
16
Warning
: Trying to access array offset on value of type null in
/htdocs/search/index.php
on line
16
Voyez-vous comment faire ??