Hola de nuevo
Estoy extrayendo los datos de un xml con:
Código PHP:
$xml = simplexml_load_file("http://productoType=2",'SimpleXMLElement');
foreach($xml->product as $fila){
$fila->categories->category;
$fila->description
}
Con $xml->xpath("/products") extraigo (p.e):
Código HTML:
[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 )
) )
categories lo extraigo sin problemas $fila->categories->category
El p roblema lo tengo con esta secuencia:
Código HTML:
[1] => SimpleXMLElement Object ( [@attributes] =>
Array (
[name] => manufacturer )
[value] => Nike)
Con $marca= (string)$fila->properties->property[1]->attributes(); coonsigo extraer la palabra manufacturer, mi objetivo es conseguir extraer la palabra Nike.
He intentado con:
$marca= (string)$fila->properties->property[1]->attributes()->value; //creo que debería ser la correcta.
$marca= (string)$fila->properties->property[1]->attributes()->value[0];
$marca= (string)$fila->properties->property[1][0]->attributes()->value;
$marca= (string)$fila->properties->property[1][1]->attributes();
$marca= (string)$fila->properties->property[1]->attributes(value);
y etc..
A alguien le ha pasado lo mismo? A alguien se le ocurre algo? un saludo gracias....