RSS/XML feed parser

Here's some php:

function xml_parser($page,$container,$tags,$number,$cdata) {
  if (!$number) {$number=100;}
  preg_match_all("/<$container>.+<\/$container>/sU",$xml, $items);
   foreach ($items as $item) {
    for($i=0; $i<count($tags); $i++) {
    preg_match("/<$tags[$i](.+)(<\/$tags[$i]>)/sU", $item, $tag);
    $this[$i]=array_map('html_entity_decode', $this[$i]);
     if (count($itemsArray)<$number) {array_push($itemsArray, $this);}
  foreach ($itemsArray as $item) {
  for($i=0; $i<count($tags); $i++) {
  $data[$i]=$item[$i][0];    }
   $dpatterns[0]="/<img(.+)><\/img>/sU"; $dreplacements[0]='<img$1>';
   $dpatterns[1]="/<img(.+)\/>/sU"; $dreplacements[1]='<img$1>';
   $dpatterns[2]="/<(\/|)content?(.+|)>/sU"; $dreplacements[2]='';
   $dpatterns[3]="/border=\"0\"/sU"; $dreplacements[3]='';
   if ($cdata!='hide') {
    $dpatterns[4]="/<\!\[CDATA\[(.+)\]\]>/sU"; $dreplacements[4]='$1';
   else {
    $dpatterns[4]="/<\!\[CDATA\[(.+)\]\]>/sU"; $dreplacements[4]='';
   <dt><a href=\"$link\">$title</a></dt>
   <dd class=\"story\">$description</dd>
   <dd>Date: $date</dd>\r";
return $theData;



Here's some HTML with PHP

<?php echo $bbc; ?>
<?php echo $cnn; ?>
<?php echo $flickr; ?>

Here's what we get... (the lastest feeds from the BBC, CNN, and flickr).


Patients in England are struggling to get hold of drugs such as painkillers and anti-depressants.
Date: Fri, 18 Jan 2019 02:03:05 GMT
Speed cameras are also expected to be installed on the road where the Duke of Edinburgh's car overturned.
Date: Fri, 18 Jan 2019 05:08:28 GMT
Israeli student Aiia Maasarwe was attacked while on the phone to her sister, police say.
Date: Fri, 18 Jan 2019 04:00:22 GMT
The government may block the Speaker from getting a peerage when he retires, a source suggests.
Date: Fri, 18 Jan 2019 02:28:26 GMT
Japanese officials are trying to work out whether the famous British street artist has paid a visit.
Date: Fri, 18 Jan 2019 02:17:54 GMT
Half a million people chose a grey car in 2018 making it the most popular colour for the first time.
Date: Fri, 18 Jan 2019 00:00:48 GMT
Rory Stewart suggests there could be some give and for the PM when it comes to Brexit talks with other parties.
Date: Thu, 17 Jan 2019 22:55:25 GMT
The man is questioned over claims he racially abused a waitress at a force's Christmas party.
Date: Fri, 18 Jan 2019 05:00:24 GMT
Members of Congress who were due to join the trip are left sitting on a bus at Capitol Hill.
Date: Thu, 17 Jan 2019 23:47:39 GMT
Some councils aim to fill potholes within minutes but others take more than a day, new figures show.
Date: Fri, 18 Jan 2019 01:14:39 GMT


President Donald Trump personally directed his longtime attorney Michael Cohen to lie to Congress about the Moscow Trump Tower project, two federal law enforcement officials involved in an investigation of the matter told BuzzFeed.
Date: Fri, 18 Jan 2019 05:13:45 GMT
President Donald Trump was startled Tuesday as he watched television coverage of his nominee for attorney general describing a warm relationship with the special counsel Robert Mueller in front of the Senate Judiciary Committee, according to three people familiar with the matter.
Date: Thu, 17 Jan 2019 23:50:29 GMT
Marci Whitaker, the wife of acting Attorney General Matthew Whitaker, sent an email to a reporter pushing back on an article and said the special counsel investigation was by all accounts "wrapping up."
Date: Fri, 18 Jan 2019 00:58:28 GMT
Former Director of National Security James Clapper discusses Attorney General nominee William Barr's testimony and views on special counsel Robert Mueller with CNN's Don Lemon.
Date: Wed, 16 Jan 2019 10:30:15 GMT
Ever since special counsel Robert Mueller began his investigation of Russian interference in the 2016 election, public interest in the law, crime and justice has surged. Over the past few months, I've received countless questions -- creative, unexpected, brilliant and challenging -- from viewers and readers. People are keenly interested in learning about our legal system, perhaps like never before.
Date: Thu, 17 Jan 2019 20:35:31 GMT
After President Donald Trump's lawyer Rudy Giuliani conceded that members of the Trump campaign colluded with Russians, CNN's Anderson Cooper questions whether Giuliani was getting ahead of special counsel Robert Mueller's next move.
Date: Fri, 18 Jan 2019 02:56:37 GMT
President Donald Trump's former "fixer" Michael Cohen paid the head of a small technology company thousands in 2015 to rig online polls and elevate Cohen's character to benefit Trump's presidential campaign, The Wall Street Journal reported Thursday.
Date: Thu, 17 Jan 2019 21:17:44 GMT
The Supreme Court will meet behind closed doors on Friday to discuss a mystery case related to special counsel Robert Mueller's investigation.
Date: Thu, 17 Jan 2019 22:44:43 GMT
The Trump administration was drafting policy to separate families apprehended at the U.S.-Mexico border as early as 2017, despite later claims that no such policy existed, according to a draft memo released Thursday night.
Date: Fri, 18 Jan 2019 05:07:33 GMT
The White House has canceled the planned delegation's trip to Davos, Switzerland, for the World Economic Forum, press secretary Sarah Sanders announced Thursday, the 27th day of government shutdown.
Date: Fri, 18 Jan 2019 01:01:46 GMT


2017-11-23 BK 010 D3K2 GA2_SKHSBS.jpg

HKSSF posted a photo:

2017-11-23 BK 010 D3K2 GA2_SKHSBS.jpg

Date: 2019-01-18T05:44:16Z

hldocker posted a photo:


Date: 2019-01-18T05:44:17Z
Vui đi em - Soobin Hoàng Sơn

nhacloivn posted a photo:

Vui đi em - Soobin Hoàng Sơn

Vui đi em - Soobin Hoàng Sơn
Bài hát: Vui đi em

Sáng tác: Soobin Hoàng Sơn

Điệu:Điệu:Chưa chọn

Giáng (b)
Hợp âm:
Thăng (#)

(Tăng cỡ chữ)
x2 (Nhân đôi lời)

Vòng hợp âm: [Em] [Bm] [Am] [Am]

[Em] Có bờ vai của ai thật sexy [Bm] lady
Nhìn đằng [Am] xa thấp thoáng dưới những màu sắc sau tấm lụa rơi
Show [Em] me oh let me show [Bm] you babe
Ai [Am] đó có cho em ngọt ngào bằng anh.

Theo [Em] dấu chân em đi vào từng giấc [Bm] mơ
Anh đã cố [Am] níu giữ em ở lại và yêu em say đắm hết đam mê này
Em mà [Em] thích gì anh đây cũng chiều em tới [Bm] nơi
Lại gần [Am] bên anh chỉ một phút giây cảm nhận nọ

Vui với em quên cả đường [Em] về về...[Bm] về
Và tình [Am] yêu đó càng thêm lâu
Thì về sau nó sẽ càng đậm sâu.

Vui với em quên cả đường [Em] về về...[Bm] về
Một người [Am] luôn đứng ở đằng sau
Chỉ muốn giữ lấy mình bên nhau.

[Em] OK! Cuộc chơi này chỉ giành riêng cho hai ta
[Bm] Phiền mấy cô em gái khác hãy tránh ra
[Am] Say xưa hoài niệm về những thứ đã qua
Đừng nói với anh là "Anh ơi em muốn về nhà"
[Em] Cuộc sống của anh khi có em trôi qua vẫn thế
[Bm] Cuộc sống của em khi có anh trôi qua vẫn vậy
[Am] Tình cảm của anh dựa trên những cảm giác
Giống như những lúc anh flow theo điệu nhạc.
[Em] Lá lá la ....
[Bm] Lá lá la...
Anh đã cố [Am] níu giữ em ở lại và yêu em say đắm hết đam mê này
Anh không [Em] biết làm được điều gì
Và anh không [Bm] biết phải làm thế nào
Để giữ [Am] em là của anh thôi nhá.

Vui với em quên cả đường [Em] về về...[Bm] về
Và tình [Am] yêu đó càng thêm lâu
Thì về sau nó sẽ càng đậm sâu.

Vui với em quên cả đường [Em] về về...[Bm] về
Một người [Am] luôn đứng ở đằng sau
Chỉ muốn giữ lấy mình bên nhau.

* [Em] Em đang mơ giấc [Bm] mơ nào
Với [Am] ai nói với anh nghe này
Có vui hay là cười trong nước mắt.

[Em] Chỉ cần bàn tay giữ [Bm] anh lại
Trái [Am] tim sẽ theo em mãi mãi.

Nghe bài hát Vui đi em:

Soobin Hoàng Sơn

Date: 2019-01-18T05:44:18Z

Miguel Discart (Photos Vrac) posted a photo:


WWE WrestleMania XXXI - Las Vegas - San Jose - Los Angeles - Wrestlemania XXXI

The granddaddy of them all

( Our Tour in Las Vegas, San Jose and Los Angeles for Wrestlemania 31 from San Jose )

Date: 2019-01-18T05:44:18Z
P1140470 (2).jpg

punimoe posted a photo:

P1140470 (2).jpg

Olympus digital camera

Date: 2019-01-18T05:44:01Z

minarsamy527 posted a photo:


Date: 2019-01-18T05:44:07Z

North Metropolitan TAFE posted a photo:


Date: 2019-01-18T05:44:12Z

anne-kathrin.knappe posted a photo:


Date: 2019-01-18T05:44:18Z

virgoliu239851 posted a photo:


Date: 2019-01-18T05:44:21Z
Bistro Design

homedesignbest posted a photo:

Bistro Design

Home Design
Bistro Design – Top Design Inspiration Decoration Bistro Design.
My clients love that I work with them as a trusted, creative business partner who is invested in their long term success. “Veronica has a unique ability to feel the essence of your brand and pull it out of you in words ...
bar design, best cafe design, bistro, bistro apetit zagreb, brand design, design, designer, designs, graphic design, identity design, industrial design, interior design, interior design (industry), interior design 2017, interior design firm, interior design ideas, interior design new, interior designer, kitchen, kitchen design, kitchen designs, logo design, redesign, restaurant, restaurant design, top house design, web design, website design, zero due design

Date: 2019-01-18T05:44:01Z


2007-03-02 dumb_dave says :

Sorry, I'm new to this stuff, willing to learn and all that, but I don't get the idea. Copy that snippet of PHP code into a file and call it, say, parser.php. Copy the other snippet of HTML into a file and call it, for lack of inventiveness, parser.html. Right so far? If so, where's the intermediate step? How does this HTML "call" or "include" the PHP in order to function? Or am I missing something so basic that even asking this will earn me the cherished "Idiot of the Day Award"? Thanks.

2007-03-02 BonRouge says :

You can include the php or just have it in one page. The page would have a '.php' extension - not '.html.'
Here's a simple example of this page (with no style or anthing) in one file.
Save it and change the extension to '.php'. If you don't have a server installed on your machine, you'll have to upload it to a remote server to view it.
If you want, you can take the php code out of that page and save it in a different file and include it into the page - that way, you could use it on more than one page if you wanted.

I hope that makes it a bit clearer.

2007-03-02 dumb_dave says :

Thanks for the explanations. Much clearer now and ... yes, it indeed works like a champ. (Maybe I was just too tired? Putting 1 and 1 together and coming up with 11 instead of two?) Best regards and thanks for all the tips elsewhere as well.

2007-03-07 dumb_dave says :

Useful indeed, BonRouge, but how does one display the <description> tagged material that is buried behind things like <![CDATA[ <p> etc.? Is the PHP code easily modified to handle that? And if so, can one apply it selectively? That is, show the fuller "description" material for one site but then reduce the next site entry to "headines" only (i.e., "titles" and "links") and then toggle the next one back to fuller details? Hope this is not a major headache, but it's beyond my ability to work it out at this stage ... and everything tried brought the larger process to a grinding halt. (This isn't a do-my-homework-for-me question. I'm bewildered by the code.) Thanks.

2007-03-07 BonRouge says :

I thought I'd already sorted out the problem of data wrapped in the CDATA stuff. Does the code have a problem? If you could show me where it's not working, I'll try to improve it.
As for choosing whether to show that particular data or not, yes - I think you could do that by adding another variable. You see near the top where there's a preg_replace() to remove the CDATA tags? You could put that in an if statement - if the variable is not present, remove the CDATA tags, if it is, leave them where they are.
Does that make sense?

2007-03-10 BonRouge says :

I think I found the problem and sorted it out. As you can see, it seems to work OK now. Some of the characters in the Lockergnome feed don't show right on this page though. I wonder if it's anything to do with me being in Japan. Do you see strange characters?

2007-05-01 Ice says :

I have been trawling the web for days looking for something like this. Thanks a WHOLE lot man. I was also wondering if you can modify this parser to merge these fields and display, say, only the latest 10 items? wine

2007-11-02 steve says :

thanks sorted out my cdata parasing problem, seems that is not too clear in the docs


Comment form

Please type the word 'Liverpool' here:

BB code available :

  • [b]...[/b] : bold
  • [it]...[/it] : italic
  • [q]...[/q] : quote
  • [c]...[/c] : code
  • [url=...]...[/url] : url