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

  • Home
  • SEARCH
  • 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 6555243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:47:45+00:00 2026-05-25T12:47:45+00:00

I am parsing into PHP an RSS feed from the national data buoy center.

  • 0

I am parsing into PHP an RSS feed from the national data buoy center. I am not able to parse in the description which is tagged as CDATA. The end goal is to have the description items variables such as Location, Wind Direction, Wind Speed, etc.. I am unsure how to break this out and omit the tags.

Here is a snippet of the feed:

<item>
  <pubDate>Thu, 08 Sep 2011 17:59:39 UT</pubDate>
  <title>Station SFXC1 - SAN FRANCISCO BAY RESERVE, CA</title>
  <description><![CDATA[
    <strong>September 8, 2011 9:45 am PDT</strong><br />
    <strong>Location:</strong> 38.223N 122.026W or 77 nautical miles S of search location of 39.5N 122.1W.<br />
    <strong>Wind Direction:</strong> W (270&#176;)<br />
    <strong>Wind Speed:</strong> 11 knots<br />
    <strong>Atmospheric Pressure:</strong> 30.03 in (1017.0 mb)<br />
    <strong>Air Temperature:</strong> 62&#176;F (16.9&#176;C)<br />
    <strong>Dew Point:</strong> 50&#176;F (10.2&#176;C)<br />
  ]]></description>

  <link>http://www.ndbc.noaa.gov/station_page.php?station=sfxc1</link>
  <guid>http://www.ndbc.noaa.gov/station_page.php?station=sfxc1&amp;ts=1315500300</guid>
  <georss:point>38.223 -122.026</georss:point>
</item>

Here is the PHP:

$feed_url = "http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=39.5&lon=-122.1&radius=400";
$xmlString = file_get_contents($feed_url); 
$xmlString = str_replace('georss:point','point',$xmlString);  
$xml = new SimpleXMLElement($xmlString); 
$items = $xml->xpath('channel/item');
$closeItems = array(); 
$new_array = array(); 
foreach($items as &$item)  
{ 
echo "<br>";
$item_title = $item->title;
$item_title = mb_convert_case($item_title, MB_CASE_UPPER, "UTF-8");
list($lat, $lng) = explode(' ',trim($item->point));
   echo $item_title;
echo "<br>";     
echo $lat;
echo "<br>";
echo $lng;
echo "<br>";
echo $item->description;
echo "<br>";
echo $item->pubDate;
echo "<br>";
} 
  • 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-05-25T12:47:46+00:00Added an answer on May 25, 2026 at 12:47 pm

    Rewrote my solution to actually be correct:

    $feed_url = "http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=39.5&lon=-122.1&radius=400";
    $xmlString = file_get_contents($feed_url); 
    $xmlString = str_replace('georss:point','point',$xmlString);  
    $xml = new SimpleXMLElement($xmlString); 
    $items = $xml->xpath('channel/item');
    foreach($items as $item) { 
    
    $item_title = mb_convert_case($item->title, MB_CASE_UPPER, "UTF-8");
    $description = mb_convert_case(str_replace('        ', '', trim(html_entity_decode(strip_tags($item->description)))), MB_CASE_UPPER, "UTF-8");
    
    list($lat, $lng) = explode(' ',trim($item->point));
    
    echo $item_title . PHP_EOL . $lat . ' x ' . $lng . PHP_EOL . 'published: ' . $item->pubDate . PHP_EOL . 'Description: ' . PHP_EOL . $description . PHP_EOL . PHP_EOL;
    }
    

    I took the CDATA removed the tags, decoded the html entities, and removed the pesky white space. A regex might be better in removing the white space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing a CSV data feed sent to me via php. I am
I am parsing an xml file from an API which I have converted into
I'm able to consume a local WSDL into PHP, and pass/return basic data successfully,
I'm taking array output from a command-line program and parsing it into a PHP
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
Apart from just inserting and parsing text into a blank Word field, is there
I'm running into memory issues with PHP Simple HTML DOM Parser. I'm parsing a
I am using PHP to read in a .txt file, and parsing the data
Seeking suggestions from PHP architects! I'm not terribly familiar with PHP but have taken
Pulling simplexml and parsing them into php variables. I have a form with arrays

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.