builder eredeti hozzászólása
Egy xml filet kellene átalakítanom, ehhez első lépésben olvasni szeretném, de baj van.
Az xml struktúrát olvasom, de az ár így néz ki:
<Prices>
<Vat>27%</Vat>
<Price>
<Type>normal</Type>
<Net>9448.8189</Net>
<Gross>12000</Gross>
</Price>
<Price>
<Type>sale</Type>
<Net>3141.7323</Net>
<Gross>3990</Gross>
</Price>
Nekem ebből a 3990 kellene, de nem tudom hogy férek fozzá.
A kód (alul) az a <Type>normal</Type> hoz tartozó <Gross>12000</Gross> szal tér vissza.
$xml = simplexml_load_file("input.xml") or die("Error: Cannot create object");
foreach($xml->children() as $product) {
echo $product->Name . ", ";
echo $product->Id . ", ";
echo $product->Sku . ", ";
echo $product->Categories->Category->Name . ", ";
echo $product->Description->Short . ", ";
echo $product->Url . ", ";
echo $product->Images->Image->Url->Medium . ", ";
echo $product->Prices->Price->Gross . ", ";
Utolsó sor a baj!! HELP légyszíves!!
PHP kód:
echo $product->Prices[1]->Price->Gross . ", ";
Könyvjelzők