我对XML解析有问题:
<pricecatalog>
<pricecathdr></pricecathdr>
<listofcatalogdetails>
<catalogitem>
<product>
<productid>1515159115</productid>
</product>
</catalogitem>
<catalogitem>
<product>
<productid>251541851</productid>
</product>
</catalogitem>
<catalogitem>
<product>
<productid>15181158</productid>
</product>
</catalogitem>
</listofcatalogdetails>
</pricecatalog>
我使用DOM来解析它:
$doc = new DOMDocument();
$doc->loadXML($this->response);
$items = $doc->getElementsByTagName("catalogitem");
$i = 0;
foreach($items as $itm){
$i++;
}
echo $i;
我认为如果解析会成功,我必须得到2但是我得到0。