Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    San Jose, CA
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RSS Feed (No "channel" or "item")

    I'm trying to use the following feed:
    http://www.nws.noaa.gov/data/current_obs/KACV.xml

    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:
    http://www.rjk-hosting.co.uk/programs/prog.php?id=7

    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.
    -ts
    -Challenge The Status Quo
    -www.toddseal.com/rodin

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

    Edit:
    Oh look, heres the rss feed for it: http://www.nws.noaa.gov/data/current_obs/KACV.rss
    Good to go
    Last edited by Fou-Lu; 09-18-2005 at 06:53 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    San Jose, CA
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    -ts
    -Challenge The Status Quo
    -www.toddseal.com/rodin

  • #4
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    I'd take a look at xmlize.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    Last edited by Fou-Lu; 09-18-2005 at 11:52 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #6
    Regular Coder
    Join Date
    May 2004
    Location
    San Jose, CA
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, folks. I'll look more into XMLize later. That looks like what I would hav needed. For now, I've used this:
    http://us2.php.net/manual/en/ref.xml.php#26836

    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.
    -ts

    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).
    -Challenge The Status Quo
    -www.toddseal.com/rodin


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •