0
我在此進料計數總項的問題,計數在ATOM項目總飼料
$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;
結果,
這樣做的內容飼料是這樣的,
<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>