pizza.php

<?php
    // working with XML
    $xml = simplexml_load_file("data/pizza.xml");
    
    var_dump($xml);
    echo "<hr>";
    
    foreach($xml->children() as $child) {
        echo "(";
        foreach ($child->toppings->children() as $topping)
            echo "$topping, ";
        echo ") {";
        foreach ($child->attributes() as $attrName => $attrVal) 
            echo "$attrName: $attrVal,";
        echo "}";
        
        echo $child->toppings . ", ";
        echo $child->sauce . ", " . $child->price . "<br/>\n";
    }
    
    
        
    foreach($xml->children() as $child) {
        foreach ($child->children() as $grandchild) {
            echo $grandchild->getName() . ": " . $grandchild . " <br>\n";
        }
    }

pizza.xml

<?xml version="1.0" encoding="utf-8" ?>
<pizzas>
    <pizza size="large">
       <toppings>
           <topping>Pepperoni</topping>
           <topping>Extra Cheese</topping>
       </toppings>
       <sauce>Tomato</sauce>
       <price>13.00</price>
    </pizza>
    <pizza size="x-large">
       <toppings>
           <topping>Mushroom</topping>
           <topping>Olive</topping>
       </toppings>
       <sauce>Tomato</sauce>
       <price>15.00</price>
    </pizza>
    <pizza size="medium">
       <toppings>
           <topping>Cheddar</topping>
       </toppings>
       <sauce>BBQ</sauce>
       <price>10.00</price>
    </pizza>
</pizzas>