C
C
cloneforce2020-04-23 19:27:41
PHP
cloneforce, 2020-04-23 19:27:41

Error parsing KinoPoisk rating, why?

Good afternoon!
I ran into a problem when parsing a rating from KinoPoisk.

The code I am using:

$doc = new DOMDocument();
        $doc->load("http://www.kinopoisk.ru/rating/".$movie['kp_id'].".xml");
        $kp = $doc->getElementsByTagName('kp_rating');
        $kino_rating = $kp->item(0)->nodeValue;
        $kino_votes = ($kino_rating) ? $kp->item(0)->getAttribute('num_vote') : "";
        $kino_votes = number_format($kino_votes);


In the $movie["kp_id"] array - the movie ID.

Parsing is fine, but sometimes this error occurs:

Warning: DOMDocument::load(): Start tag expected, '<' not found in www.kinopoisk.ru/rating/840817.xml, line: 1 in

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question