Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9209143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:46:22+00:00 2026-06-18T00:46:22+00:00

I am trying to parse data from an xml or rss file. It is

  • 0

I am trying to parse data from an xml or rss file. It is a bit of a mess. People tell me that its meant to be easy but I am struggling alot.

First I want to get the radio shows news to display on site. I got the rss feeds and api both from an external source and they update the xml content daily and I just need to get the file and save it on my server so I can read off it.
Here is a sample of the rss.

<?xml version="1.0"?>
   <channel>
        <title>external source</title>
        <link>http://www.externalsource.com/</link>
        <description>external source</description>
        <language>en-us</language>
        <pubDate>Thu, Jun 3 2011 10: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.externalsource.com</link>
        </item>

      <item>
         <title>- Stephen Ace show</title>
         <link>http://www.externalsource.com/stephen_ace</link>
         <description>Stephens show</description>

      </item>
      <item>
         <title>- Sarah Hardy show</title>
         <link>http://www.externalsource.com/sarah_hardy</link>

     <description> Sarah's first show in her new slot.</description>
      </item>
      <item>

         <title>- Radio 4 evening show</title>
         <link>http://www.externalsource.com/shows/id-453</link>
         <description>Bill Grady is supported by co-host Lenny Hillroy</description>
      </item>
      <item>
         <title>- Kiss music evening show will Sady</title>
         <link>http://www.externalsource.com/shows/id-112</link>

         <description>Sady presents the evening show here at Kiss.</description>
      </item>
         </channel>

I save this file as tonight.xml and it updates evening 24 hours from a PHP script which uses fread().

I want to show just the titles of the shows that are playing that evening, nothing else.
I am ok with MySQL but am really not getting this. I am very stuck.
Here is my php

<?php

$thexml = simplexml_load_file("tonight.xml");

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

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

When I test it it does not print the correct values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:46:23+00:00Added an answer on June 18, 2026 at 12:46 am

    A quick solution using the SimpleXMLElement::xpath() function:

    $thexml = simplexml_load_file("tonight.xml");
    
    foreach ($thexml->xpath('//item/title') as $title) {
        echo $title, "<br>\n";
    }
    

    You find more Xpath resources here:

    • What is an excellent XPATH reference for learning correct usage of the syntax?, PHP uses Xpath 1.0 as of today.

    Next to SimpleXML there is also DOMDocument, the big sister of it:

    libxml_use_internal_errors(true);
    
    $dom = new DomDocument();
    if ($dom->load('tonight.xml')) {
      $xpath = new DomXPath($dom);
      foreach ($xpath->query('//item/title') as $node) {
        echo $node->nodeValue, "<br>\n";
      }
    }
    

    That should work

    You will get it, just focus on filling in all the gaps you find in your knowledge and you will get there.

    Read up on DomDocument and DomXPath in them PHP manual here:

    • http://php.net/class.domdocument
    • http://php.net/class.domxpath
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse an xml file and extract data from it to display
I'm reading from an xml file and trying to parse the data to a
I am trying to parse data from the XML below (I shortened the data
I am trying to parse data from a xml page through sax parsing technique.The
Hi I am trying to parse data out of an XML file I exported
Greetings, I am trying to parse live weather data from Weatherbug's RSS feed in
I am trying to parse data from a xml web service but I am
Hello I am trying to create an ASyncTask that will parse data from an
I am trying to return some data retrieved from an xml file and then
I am trying to parse the abstract part from the XML file. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.