|
Posted by lhenkel on 11/24/06 16:58
This is idiotic, but I can't figure this out:
I can do this:
$xml = new SimpleXMLElement('<items>
<item><name>Lee</name><count>1</count></item>
<item><name>Bill</name><count>5</count></item></items>');
foreach ($xml->item as $item) {
echo $item->name, '<br />';
}
But I can't figure how to tell I have 2 items. The obvious:
print count($xml->item); // same for $xml->items
and
print $xml->item->length; // same for $xml->items->length
They don't work the way I expect..
This is my first foray into XML, so I'm sure I'm doing something
stupid.. would anyone mind pointing it out?
Thanks,
Lee
Navigation:
[Reply to this message]
|