可能会有重复,但我迄今为止没有找到有用的东西。
我正在尝试使用simplexml
计算XML
文件中的节点/子节点
数量。
我尝试了以下代码。
$xml = simplexml_load_file("./file.xml");
echo count($xml->rss->channel->item);
并且
echo count($xml->item);
但仅仅输出0
。
这里是XML
的快照。
<?xml version="1.0"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<item>
<title>PUDRA Pudra Ceket Ceket</title>
<link>http://www.trendyol.com//Pudra-Ceket-IW6140005046/UrunDetay/31066/9188683?</link>
<description>36 pudra pudra ceket ıw6140005046 ipekyol ceket kadın</description>
<g:urunid>1423905</g:urunid>
<g:id>1423905_14</g:id>
</item>
<item>
....
</item>