0

I have simple XML element called $element but I can't manage to get specific result. For example I want value of specific attribute.

For example I need value for attribute named "Product" so expected result is "XYZ top".

SimpleXMLElement Object
(
  [attribute] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [name] => Product
                        )
                )
            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [name] => Price
                        )
                )
            )
 [value] => Array
        (
            [0] => XYZ top
            [1] => 999.25
        )
)

Did not manage to find solution elsewhere. Tried this and many other things:

echo $element->attributes()->{'Product'};

foreach($element->specification as $dat) {
    foreach ($dat->attributes() as $a => $b) {
        echo $a,'="',$b,'"';
    if ($b=='Product') {
    echo "right one";
            }
}
echo " -> ".$dat."<br>";
}
Ivan
  • 171
  • 2
  • 12

0 Answers0