Skip to content

Commit

Permalink
add bbc atom example test
Browse files Browse the repository at this point in the history
  • Loading branch information
pejman-hkh committed Sep 16, 2023
1 parent 32595fd commit f12fc18
Show file tree
Hide file tree
Showing 2 changed files with 680 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/bbc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
include __dir__.'/../vendor/autoload.php';

function file_cache_content( $url ) {
$file = __dir__.'/data/'.md5( $url );
if( file_exists( $file ) )
return file_get_contents( $file );
file_put_contents( $file, $c = file_get_contents( $url ) );
return $c;
}

$p = new \Pejman\DomParser\Parser( file_cache_content('http://feeds.bbci.co.uk/news/stories/rss.xml') );

foreach( $p->find("channel item") as $item ) {
echo $item->find("title",0)->html()."\n";
}
Loading

0 comments on commit f12fc18

Please sign in to comment.