Web Design Forums

Welcome! Please register or log in: Forgot your password? Why register?
You are here: Web Design Forums » Programming Help » PHP » Importing info from xml feed into php RSS

Importing info from xml feed into php

This thread was started by ash.kendall and has been viewed 762 times, and contains 8 replies, with the last reply made by Danny[MLWA].
Post Reply
1
View ash.kendall's reputation
Posted June 13 '09 at 02:03 PM
      Posts: 24
Hi guys,

I'm trying to build an web application that will generate a schedule for cinema times. Basically, the showtimes for a film are taken, along with the film length, and a table is made showing all the films together so you can see where they overlap, when they finish etc.

So they don't have to be entered manually I've got the listings from the Cineworld site and want (for now) the full guide to be shown. Problem being, I haven't got a clue how to use it!

The link given by Cineworld is here. I'm wanting to import the info from listings.xml so I can provide a list of cinemas and then the films and showtimes from that cinema. I'm hoping that I can import some info from the all-performances.xml file too as that contains info (like the run-time) of the films.

So, any suggestions?! I've searched and found a few guides that are aimed at RSS news feeds but none of these look like they'll apply in this case.

Any help is appreciated!

Advertisement Register for free to hide these ads and participate in discussions!

2
1,251 points at 99% Moderator Repute
mlseim, WDF Moderator Private message  
Posted June 13 '09 at 03:39 PM
      Posts: 3,100
Describe how you plan on displaying the information.
I mention this because the XML files are large and there are many different movie times.

How much of the information are you planning on displaying? ...
and better yet, show us an example web page that you're working on
with some fake info entered, so we an see how your final thing is supposed
to look. This is important because of the different ways to read the XML file.

Give us a link to your URL.
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?

3
View ash.kendall's reputation
Posted June 13 '09 at 04:02 PM
      Posts: 24
I've had a few problems deciding on how the information will be displayed. I'd like to be a sort of time-table appearance, the hours of the day across the top and blocks displaying the time the film is showing.

I've not actually built anything yet because I'm not sure how I'm going to get the info in the site. I was hoping that I could start once I figured a way of getting the info I want from the XML file into a page. Then I could manipulate it.

The plan was to select the preferred cinema (e.g. Sheffield) and the date you would like to see the schedule for, and then the films and times for them would be displayed in the timetable format.

I'm basically just looking for a way to get the info from the XML files into a php array. I've just found a site that does something very similar here.

4
44 points at 77%
Dorky, Freelance Home page   Private message  
Posted June 13 '09 at 04:06 PM
      Posts: 789
just wanted to mention before getting started that on the example link given the details vs dates time doesnt work on my setup.


ubuntu jaunty / firefox3
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein

5
58 points at 100%
imagn, WDF Addict! Home page   Private message  
Posted June 14 '09 at 06:08 AM
      Posts: 156
Import the data into MySQL (equivalent) using the DOM library. This is by no means a complete example but...

$file_name = "feed.xml";
$doc = new DOMDocument();
$doc->load($file_name);
$toplevel = $doc->getElementsByTagName("a");

// NEEDS TO LOOP THROUGH EACH ELEMENT AND GRAB RESPECTIVE VALUE
foreach( $toplevel as $a) {
$node_1_var = $a->getElementsByTagName("b");
$node_1_val = $node_1_var->item(0)->nodeValue;
// ect....
}

6
794 points at 99% Donor Moderator Repute WDFplus Member
Posted June 14 '09 at 10:46 PM
      Posts: 11,793
I was about to suggest the DOM library too (annoyingly, domxml in PHP 4). Essentially it's identical to the DOM in Javascript, so if you've used it there, it should be pretty easy in PHP.

If you want to quickly (at least, few lines of code) retrieve certain nodes from XML, you might want to use XPath, also supported by the PHP DOM library.
filburt1, Web Design Forums.net founder
Want to advertise on this site?
Site of the Month contest: submit your site or vote for the winner!

7
32 points at 100%
Posted June 18 '09 at 03:08 AM
      Posts: 76
I've seen problems with using DOM -- and cvsimport as well. Basically if the RSS feed isn't perfect it errors out. For that I use my own script... Its not perfect but I use Curl to grab the raw text then use my own parser through php to sort and sift the data... If you tell it to only look for certain tags from there and to explode the document into those fields, it works with extreme consistantcy even if they have errors in thier rss as the script won't care.
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul

8
794 points at 99% Donor Moderator Repute WDFplus Member
Posted June 18 '09 at 05:49 PM
      Posts: 11,793
If the RSS feed isn't well-formed XML you'll have a hell of a time trying to get anything out of it.

You can try passing it through something like Tidy to fix it.
filburt1, Web Design Forums.net founder
Want to advertise on this site?
Site of the Month contest: submit your site or vote for the winner!

9
32 points at 100%
Posted June 18 '09 at 06:02 PM
      Posts: 76
he he...

$row explode('<channel>'$curled);
for (
$i=0;$i<count($row);$i++)
{
$title_a explode('<title>'$row[$i]);
$title explode('</title>'$title_a[1]);
// Use as $title[0]; and repeat for each data field you want to dump into the database =)


Been using that setup for RSS feeds and CVS imports for years.
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul

Post Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Top 21 PHP Programming mistakes thexchord PHP 18 March 10 '10 08:52 AM
The future of Web Design Forums.net filburt1 Announcements 128 January 30 '10 04:27 AM
PHP / XML - Please Help!! Lunarben PHP 6 April 1 '09 11:27 AM
How to run ExamXML from PHP to compare XML files. alapick PHP 1 April 29 '07 08:15 PM
Request for PHP and ASP Info lmarshall General Design Discussion 4 April 28 '03 03:05 PM