我不知道这是怎么回事。我遵循了PHP文档中的说明。
这是我的代码:
$xmlfile = simplexml_load_file($xmlurl) or die("Cannon get.");
该文件包含以下模式:
<PriceResult>
<QueryStatus>
</QueryStatus>
<InputData>
</InputData>
<Producers/>
<Prices>
<Price>
</Price>
<Price>
<PartId>13580448730</PartId>
<BrandId>11</BrandId>
<Brand>BERU</Brand>
<PartNumber>Z226</PartNumber>
<PartNumberShort>Z226</PartNumberShort>
<PartDescriptionRus/>
<Price>8.90</Price>
<Currency>EUR</Currency>
<Quantity>0</Quantity>
<QuantityType>EQUAL</QuantityType>
<PriceLogo>GLIR</PriceLogo><Weight/>
<PriceDescrShort>Европейский поставщик запчастей</PriceDescrShort>
<PriceDescrLong>Европейский поставщик запчастей</PriceDescrLong>
<DeliveryType>LOCAL</DeliveryType>
<DeliveryDays>17</DeliveryDays>
<PriceChangeDate>2015-01-05 10:27:05</PriceChangeDate>
<DamagedFlag>N</DamagedFlag>
<UsedFlag>N</UsedFlag>
<OriginalFlag>N</OriginalFlag>
<OldPartNumberFlag>N</OldPartNumberFlag>
<Group>0</Group><GroupDescr/>
</Price>
<Price>
</Price>
<Price>
</Price>
</PriceResult>
我以前做过,但现在我忘了。那么,我如何通过Price-in-Prices迭代XML来获得这样的数据呢:
foreach ($xmlfile->children() as $item){
print($item->BrandId);
}
我会得到所有的品牌,或者$item->PartId-所有的零件?e.t.c到所有
$xmlfile = simplexml_load_file($xmlurl) or die("Cannon get.");
然后$xxx=$xmlfile->xxx;$yyy=$xmlfile->yyy;$zzz=$xmlfile->zzz;
毕竟,显示像这样的数据更简单
echo $xxx;
你的"->孩子()"在哪里?