N
N
nepster-web2013-12-17 17:23:04
PHP
nepster-web, 2013-12-17 17:23:04

api pb xml parser

Faced this problem:

$url = 'https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=5';
        
        $content = simplexml_load_file($url);
        echo '<pre>';
        print_r($content->row[0]);

I get:
SimpleXMLElement Object
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [ccy] => RUR
                    [base_ccy] => UAH
                    [buy] => 0.24900
                    [sale] => 0.25500
                )

        )
)

Please tell me how to solve this case

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WebSpider, 2013-12-17
@WebSpider

$content->row[0]['ccy']

N
nepster-web, 2013-12-17
@nepster-web

$url = 'https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=5';
        $content = simplexml_load_file($url);
        echo '<pre>';        
        print_r($content->row[0]['ccy']);
        print_r($content->row[0]->ccy);
        print_r($content->row[0]->attributes());
        print_r($content->row->attributes());
        print_r($content->row->attributes('ccy'));

On the screen
SimpleXMLElement Object
(
)
SimpleXMLElement Object
(
)
SimpleXMLElement Object
(
)
SimpleXMLElement Object
(
)

N
nepster-web, 2013-12-17
@nepster-web

Happened by accident somehow
$content->row[0]->exchangerate->attributes()->ccy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question