I'm trying to extract data property[value] from xml, the $xml->xpath("/products") shows:
[categories] => SimpleXMLElement Object ( [category] => Zapas )
[properties] => SimpleXMLElement Object (
[property] =>
Array (
[0] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => VAL)
[value] => 1111111 )
[1] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => manufacturer )
[value] => Nike)
[2] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => condition )
[value] => new )
[3] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => deliveryCosts )
[value] => 0.00 )
[4] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => stock )
[value] => in stock )
) )
I'm using next code for extracting xml values:
$xml = simplexml_load_file("http://productType=2",'SimpleXMLElement');
foreach($xml->product as $file){
$file->categories->category;
$file->properties????
}
The problem: I can't extract e.g Nike from:
[properties] => SimpleXMLElement Object (
[property] =>
Array (
[0] => SimpleXMLElement Object ( [@attributes] =>
Array (
[1] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => manufacturer )
[value] => Nike)...
using
$brand= (string)$file->properties->property[1]->attributes()
I got manufacturer data (name), but
$brand= (string)$file->properties->property[1]->attributes()->value
doesn't works for getting Nike (value)
How could I get property[value] data? Thanks in advance