У меня проблема с подсчетом общего количества в этом фиде,
$xml = ('http://www.huffingtonpost.com/author/index.php?author=simon-cohen'); $xmlDoc = new DOMDocument(); $xmlDoc -> load($xml); # Get and output "<item>" elements. $x = $xmlDoc -> getElementsByTagName('entry'); # Count the total feed with xpath. $xpath = new DOMXPath($xmlDoc); $total_feed = $xpath->evaluate('count(//entry)'); echo $total_feed;
результат
0
Содержание этого фида такое,
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> <title>Simon Cohen</title> <link href="http://huffingtonpost.com/author/index.php?author=simon-cohen"/> <updated>2011-11-08T11:40:28-05:00</updated> <author> <name>Simon Cohen</name> </author> <id xmlns="http://www.w3.org/2005/Atom"> http://www.huffingtonpost.com/author/index.php?author=simon-cohen </id> <rights>Copyright 2008, HuffingtonPost.com, Inc.</rights> <subtitle>HuffingtonPost Blogger Feed for Simon Cohen</subtitle> <generator>Good old fashioned elbow grease.</generator> <entry>...</entry> <entry>...</entry> </feed>
получил мой ответ:
# get and output "<entry>" elements $x = $xmlDoc -> getElementsByTagName('entry'); # Count the total feed with xpath. $total_feed = $x->length;