I’m trying to read a part of a SimpleXMLElement/XML file. The problem is I can’t get the desired text anyway I try.
I tried debugging the XML I had, so I printed it this way:
[php] foreach($response->items as $item) {
fwrite($file, var_export($item, TRUE));
}[/php]
which outputs
[php]SimpleXMLElement::__set_state(array( ‘item’ => array ( 0 => SimpleXMLElement::__set_state(array( ‘id’ => ‘000-1’, ‘description’ => ‘Notebook Prata’, ‘quantity’ => ‘1’, ‘amount’ => ‘1830.00’, )), 1 => SimpleXMLElement::__set_state(array( ‘id’ => ‘AB01’, ‘description’ => ‘Notebook Preto’, ‘quantity’ => ‘2’, ‘amount’ => ‘1340.00’, )), ), ))[/php]
But when I try to retrieve the data inside the specific items, the return is empty. I tried the following:
[php]
fwrite($file, $item->amount);
//
fwrite($file, $item->{‘amount’});
//
fwrite($file, $items->$item->amount);[/php]
But nothing seems to work.
How can I correct the syntax, to obtain the expected? I would want the file to have written ‘1830.00’ and ‘1340.00’, but I only get blanks.
XML REFERENCE:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> 2011-02-10T16:13:41.000-03:009E884542-81B3-4419-9A75-BCC6FB495EF1
REF1234 1 3 1101
49900.00 0.00 0.40 1644.80 49900.00 0.00 1 2 0001 Notebook Prata 1 24300.00 0002 Notebook Rosa 1 25600.00 José Comprador [email protected] 11 56273440 Av. Brig. Faria Lima 1384 5o andar Jardim Paulistano 01452002 Sao Paulo SP BRA 1 21.50