Jump to content

Recommended Posts

Hey! I'm trying to get a php code to read, mod and display information from an xml or RSS file.. and it's really more that a mess. Everyone told me it's easy but there must be something i'm doing wrong.

 

First, the projet is to get Tv Shows news to display on a site. I got the api and RSS feeds form TVrage.com site and they update the xml contend daily, so all I need to do is to get the file and save it on my server for faster reading. (that I know how).

Here is a sample of an rss file with the new shows that will play today :

<?xml version="1.0"?>
   <channel>
<title>TVrage</title>
<link>http://www.tvrage.com/</link>
<description>TVrage</description>
<language>en-us</language>
<pubDate>Thu, Jun 3 2010 11:23:56 PDT</pubDate>

<ttl>60</ttl>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>

<item>
<title>08:00 pm</title>
<link>http://www.tvrage.com</link>
</item>

      <item>
         <title>- Good Eats (14x02)</title>
         <link>http://www.tvrage.com/Good_Eats</link>
         <description>Grillus Domesticus</description>

      </item>
      <item>
         <title>- So You Think You Can Dance (07x03)</title>
         <link>http://www.tvrage.com/So_You_Think_You_Can_Dance</link>
         <description>Auditions #5 and #6 / Vegas Callbacks, Part 1</description>
      </item>
      <item>

         <title>- My First Place (13x05)</title>
         <link>http://www.tvrage.com/shows/id-6829</link>
         <description>Buying a Home Sight Unseen</description>
      </item>
      <item>
         <title>- WWE Superstars (02x08)</title>
         <link>http://www.tvrage.com/shows/id-22359</link>

         <description>060310</description>
      </item>
 </channel>

 

now I saved this file as today.xml on my server and it updates every 24 hours trough a php code fread() etc..

 

What I want to do is to only display the titles of the shows that will play today, no time, no description or link.

Is there a way to do that? I'm sure there is, but i'm really new to this whole xml thing and I don't get it. I mean I have no problems to work with a MySql db but this, xml, my brain just does not process it!

 

This is the piece of code I got so far from W3 schools :

<?php

$xml = simplexml_load_file("today.xml");

echo $xml->getName() . "<br />";

foreach($xml->children() as $child)
  {
  echo $child->getName() . ": " . $child . "<br />";
  }

?>

 

As you can see if you test it, it does not do quite what I want it to do.

 

P.S. I'm not sure if I am in the right  section of forum, sorry.. did not find any related articles to xml issues.

Thank's in advance 4 your help.

Link to comment
https://forums.phpfreaks.com/topic/203788-php-and-xml-is-this-the-right-forum/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.