hi i am wanting to know how many <items> there is cant seem to do it im new to php thought about counting them maybe putting them in a array or somthing also tried to loop it through and if it didnt fine one break the loop and then i have the number
$xml=("popular.xml");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; ; $i++)
{
$item_title=$x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
if ($item_title == "")
{
break;
}
}
echo $i;
so echo $i should have the number because if theres no title then it breaks ?
anyone know why it doesnt work
Fatal error: Call to a member function getElementsByTagName() on a non-object in C:\xampp\htdocs\Yavee\test.php on line 15