Outputting XML products using PHP -


i trying output name , price of following xml file using php. have managed output name using below. euro sign being output without actual price. can of show me how output price accordingly please?

foreach($product $prod) { echo $prod->name . ": " . "<br>". "&euro;" . $prod->price . "<br>"; } 

this snippet of xml file:

<pizza_menu>     <food>         <name>tal-fenek</name>         <price>             <one_slice>2.50</one_slice>             <two_slices>5.00</two_slices>             <four_slices>10.00</four_slices>             <value_pizza>9.50</value_pizza>             <family_pizza>20.00</family_pizza>         </price>     </food>      <food>         <name>maltija</name>         <price>             <one_slice>2.50</one_slice>             <two_slices>4.80</two_slices>             <four_slices>9.50</four_slices>             <value_pizza>8.50</value_pizza>             <family_pizza>17.50</family_pizza>         </price>     </food> <pizza_menu> 

since price tag contains multiple values, have loop through well.

foreach($product $prod) {     echo $prod->name . ": <br>";     foreach($prod->price $price) {         echo $price->getname() . " costs &euro;" . $price . "<br>";     } } 

hope helps.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -