i am not the best at php but have made it this far. what i am trying to do is get the first child of the xml file… i have worked out how to do the foreach and get every result but i put in the following code and just get a blank page
$url = file_get_contents("http://www.thetvdb.com/api/GetSeries.php?seriesname=house");
$xml = simplexml_load_string($url);
$seriesid = $xml->series->seriesid;
echo $seriesid;
i can do this with no issue
$url = file_get_contents("http://www.thetvdb.com/api/GetSeries.php?seriesname=house");
$xml = simplexml_load_string($url);
foreach($xml->children() as $child) {
echo '<div>Series ID: '.$child->seriesid.'</div>';
echo '<div>Series Name: '.$child->SeriesName.'</div>';
echo '<div>Language: '.$child->language.'</div>';
echo '<div>First Aired: '.$child->FirstAired.'</div>';
echo '<div>Overview: '.$child->Overview.'</div>';
}
You should use
$xml->Series[0]->seriesidinsted …Note
$xml->Seriesis an array that has so many children and the first arraykeyis0So
$xml->Series[0]is the first array and you can now pick any object in the arrayDemo : http://codepad.viper-7.com/KVJWAI
I hope this helps