View Full Version : RSS Feed (No "channel" or "item")

09-18-2005, 06:07 PM
I'm trying to use the following feed:

As you can see, nothing in the feed is inside a CHANNEL or ITEM, so none of the parsers that I've been using can get anything out of that feed except what's inside IMAGE (I'm assuming that's because the information must be one level inside something). As an experiment, I took the feed and put everything inside an ITEM tag; my reader was able to get everything out of it then.

I am using the following parser:

I am thinking that the problem is the fact that the feed I want to use has everything only one level in; it's all inside CURRENT_OBSERVATION, instead of one level deeper than that. Does anyone have an idea of how I might be able to use that feed as is? I've already thought of just setting up a CRON to pull from that feed every hour and write it to another file, adding in the ITEM tags via PHP, but I'd like to avoid that if possible. Any other ideas? Thanks for your time.

09-18-2005, 07:46 PM
The answer is simple - thats not an RSS feed. As you can see, its not simple. The script is XML (not syndicated simply), so the easiest options are to use an XML parser or the XML/XMLDOM functions of php. Without knowing your version of php, I cannot suggest whether to use XML or DOMXML.

Oh look, heres the rss feed for it: http://www.nws.noaa.gov/data/current_obs/KACV.rss
Good to go :)

09-19-2005, 12:07 AM
That RSS feed for the weather doesn't give me the level of detail I need. I did do my homework.

I know that it's an XML feed; I was just hoping that I could get the information out of it with my RSS reader. Ok, ok, maybe that sounds crazy, now that I think about it. This hit me after working on a design for about 5 hours, so I might not have been thinking clearly when I thought, "XML? RSS? They're both feeds so the same script can read them both, eh?"

I've got PHP 4.4.0 running. Is there an XML parser that you'd recommend? I'm looking here (http://www.zend.com/zend/art/parsing.php) and there (http://us2.php.net/xml) and I may be able to cobble something together. Again, thanks.

09-19-2005, 12:29 AM
I'd take a look at xmlize (http://www.hansanderson.com/php/xml/).

09-19-2005, 12:49 AM
For this I would just use the XSLT libraries, assuming you have them available:
http://ca3.php.net/manual/en/ref.xslt.php as I don't see any extra need for evaluation than nessessary. You need an XSL spreadsheet to use it though, and some XSL functions are not supported by the 4.x XSLT extension.

Oh BTW you don't need cron to do this either, as you can read and create the file on an hourly bases and store the time to a text file or database or whatever. Simply check the time, compare it to current time, if its been longer than say an hour, re-read and write the file again. You can use any number of filesystem functions or DOM functions for this.

09-19-2005, 02:46 AM
Thanks, folks. I'll look more into XMLize later. That looks like what I would hav needed. For now, I've used this:

There's a parsing error due to the EVAL in that code, but I can't seem to track it down. I turned off error reporting so it displays just fine. I also commented out the line to display the entire array and used
$ary_parsed_file['ITEM_WANTED'] to display the items I wanted. It's working well on my test site, though I can't seem to get it working from a PHP include; I have to type the code for the process directly in the page I want, instead of having PHP display it if $thisPage is, say, "weather." But that's neither here nor there.

It's working and I thank you for the help. You nudged me where I needed to be.

P.S. Good thought about not using CRON, even if I went that route. That's a good idea to check times and write to the file if it's been more than an hour (since the feed is only updated every hour).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum