matjaz/dynfetcher — pull request #1 by otobrglez (2012-07-24 18:44:09+00:00)
Title: kino-tus-maribor.php && index.php

Hi Matjaž!

1) Found a bug in your code. See file "kino-tus-maribor.php" and CustomDynFetcher method fetch(). If XML contains content in <[[CDATA ]]> markup, SimpleXML just ignores the content. I suggest you merge something like my CustomDynFetcher does so that it treats CDATA as regular string.

2) Sometimes you don't want to get first record of child as string. So I made a little change to DynFetcher class. If "mapping" array in definition contains "skip_to_string" the "process" function will get array of SimpleXMLElement-s and you can process it later on...

$itemMapping = array(
...
'ure' => array('xpath' => 'predstava/ura',
'process' => '
$out = array();
foreach($data as $ura) $out[]=array(
"ura" => (string)$ura, "cena" => (string)$ura["cena_eur"]);
$data = $out;
',
'skip_to_string' => true,
),
...
);

3) This code is not giving expected results...

$filmi = $dyn->find($itemXPath,$itemMapping);

$filmi = $dyn->find($itemXPath,$itemMapping,function(){
... code for function ...
});

$filmi = $dyn->find($itemXPath,$itemMapping,'
... code for function ...
');

I suggest you fix/rewrite code round #78 (my fork).

4) I created simple page that uses DynFetcher.
Visible here: http://dynfetcher.herokuapp.com/

Have a nice day and hope for the merge... ;)

- Oto