How to read icon information from an XML

Asked

Viewed 34 times

1

I’m trying to extract some information from a xml and I’m not getting, what I can get is the date that’s on the node weather, but icon and text I can’t seem to get them in sequence. The previous information is in a structure that repeated until then, in this case the same is changed. The code I tried to retrieve the information I need is this:

foreach($itemIcone->data->item->weather->item as $reg) {  
    // ZERANDO O ARRAY
    $data = array();

        // ÍCONES  
        $data['api']['data']['item']['weather']['item'][] = array 
        (
            // LENDO OS NÓS
            'date' => (string)$reg['date']          
        );

        // ATRIBUINDO AS VARIÁVEIS     
        $Data = $data['api']['data']['item']['weather']['item'][0]['date']; 
        $IcoManha = $data['api']['data']['item']['weather']['item'][0]['date']['icon'][0]['morning'];   
} 

The image of what I have at the moment follows below.

XML

  • You are using simplexml or domdocument? Edit your question and put the example of xml

  • Hello @Marcelodeandrade, I’m using the simplexml_load_string.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.