试图通过以下链接刮宜家页:试图从XML属性的特定值
http://www.ikea.com/it/it/catalog/products/60255550/?type=xml&dataset=prices
我想刮商品的价格,但在XML文件中的价格出现一次未格式化并且旁边有一个欧元符号。我希望特别提供价格正常的无格式值。
<prices>
<normal>
<priceNormal unformatted="44.99">€ 44,99</priceNormal>
<pricePrevious/>
<priceNormalPerUnit/>
<pricePreviousPerUnit/>
</normal>
我下面的代码不会回价格在所有的,不知道我要去哪里错了:(
$string = 'http://www.ikea.com/it/it/catalog/products/60255550/?type=xml&dataset=prices';
$xml=simplexml_load_file($string) or die("Error: Cannot create object");
//print_r($xml);
echo $xml->product->prices;
返回的值仍然具有连接到欧元符号它,我试图避免这一点,有什么建议吗? – Massive
在@ miken32的答案末尾使用'priceNormal [0] - > attributes() - > unformatted'。 – Scuzzy