mam nadzieję, że dość trafnie okresliłem temat.
Z XML do tej pory nie miałem z byt wiele do czynienia, dlatego prosił bym bardzo bardziej zaawansowanych kolegów o pomoc w rozwiązaniu problemu.
Problem dotyczy skryptu zapisującego zawartość XML (wczytywanego z adresu Url) do bazy danych. Skrypt jest automatem odpalanym cronem i do tej pory działał bez zarzutów. Dopiero w ciągu ostatnich 2 dni skrypt nagle przestał działać. Adresy url xml są nadal poprawne, a ich struktura się nie zmieniła. Nie jestem pewien, ale podejrzewam, że w niektórych elementach xml gdzie znajdują się w treści znaczniki html usunieto CDATA co pozwalało parserowi ignorować te znaczniki. Jednak to jest tylko moje przypuszczenie. Bardzo bym prosił o pomoc.. Poniżej podaje kod php mojego skryptu.
połączenie z bazą.. <?php $gruper_xml = 'http://cubegroup.go2feeds.org/feed.php?aff_id=260&offer_id=24&file_id=446&feed=aHR0cDovL2dydXBlci5wbC9yZXBvc2l0b3J5L2V4dGVybmFsL2d6aXAvdjEvZ3J1cGVyX3B
mX3NhbGVzbWVkaWEueG1s&objects=offers&object=offer&url_tag=url'; $cuppon_xml = 'http://cubegroup.go2feeds.org/feed.php?aff_id=260&offer_id=80&file_id=448&feed=aHR0cDovL2N1cHBvbi5wbC9hcGkvMjRlMGFkNjFjMTlhZTExOGQ2OTczZTRhNzE2ZGU1OWU
veG1s&objects=root&object=offer&url_tag=url&ref=24e0ad61c1&url_query=transid%3D%7Btransaction_id%7D'; foreach($movies->offers->offer as $m) { if ($m->city == 'Cała Polska') {$m->city='Polska';} if ($m->city == 'Twoja Firma') {$m->city='Firma';} $query=mysql_query("INSERT INTO tabela1 (id, city, header, short, url, category, category_id, priority, image, image_large, price, price_original, expires, why, how, program) VALUES ('$m->id', '$m->city', '$m->header', '$m->short', '$m->url', '$m->category', '$m->category_id', '$m->priority', '$m->image', '$m->image_large', '$m->price', '$m->price_original', '$m->expires', '$m->why', '$m->how', 'gruper.pl')"); } foreach($movies2->offer as $m) { if ($m->city == 'Travel') {$m->city='Podróże';} if ($m->city == 'Cała Polska') {$m->city='Polska';} $query2=mysql_query("INSERT INTO tabela1 (id, city, header, short, url, category, category_id, priority, image, image_large, price, price_original, expires, why, how, program) VALUES ('$m->id', '$m->city', '$m->title', '$m->shortTitle', '$m->url', '$m->category', '', '', '$m->image', '$m->image', '$m->price_discount', '$m->price_normal', '$end_date', '$m->important', '$m->rules', 'cuppon.pl')"); } ?>
Skrypt ten generuje następujące błędy:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 6033: parser error : Premature end of data in tag why line 6028 in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: niu Babci </strong>&ndash; luksusowy zabieg z komĂłrkami macierzystymi in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 6033: parser error : Premature end of data in tag offer line 6014 in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: niu Babci </strong>&ndash; luksusowy zabieg z komĂłrkami macierzystymi in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 6033: parser error : Premature end of data in tag offers line 4 in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: niu Babci </strong>&ndash; luksusowy zabieg z komĂłrkami macierzystymi in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 6033: parser error : Premature end of data in tag data line 2 in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: niu Babci </strong>&ndash; luksusowy zabieg z komĂłrkami macierzystymi in /grupowe/grupowe.php on line 9
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /grupowe/grupowe.php on line 9
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /grupowe/grupowe.php:9 Stack trace: #0 /grupowe/grupowe.php(9): SimpleXMLElement->__construct('<?xml version="...') #1 {main} thrown in /grupowe/grupowe.php on line 9