isn't quite ashamed enough to present

jr conlin's ink stained banana

2005-03-19

::See What Being Nice Gets You?

So in the aftermath of yesterday, Valette asked for a way to display the current weather in Fairbanks on her page. Turns out that she found an XML feed for it from NOAA, which was great, but it was in XML which she doesn't know at all. (She being someone with a life and not living and breathing this sort of crap.)

Thing is that while really powerful, PHP4's XML handling kind of sucks for quick and dirty XML parsing. (i haven't tried to screw around with PHP5 yet. That's one of the things i need to configure the box in the garage to do and there's a ton of other things tha need to be set up first)

Still, if you have a file full of simple, attribute free XML like the NOAA feed, the SAX model seems like too much work and the XML_DOM model seems like complete overkill. The sample code on the XML works great, but it returns an array of hashes. Nice, but not really the easiest thing in the world to navigate and extract data.

So i built a really simple php xml to hash function. It ignores attributes but converts a standard xml list to php hash library. i've even got a quicky little module that shows off how it works. As a bonus, this is also really useful for work. (yeah, it's ugly code, but it works. i'll probably add some additional code to automatically build out arrays of values.)

See? You help someone else and you make your own life easier.

Hey, delicious user, Save This Page
Blogs of note
personal that's my blog
(The Official Blog of the Internet)
memoirs of hydrogen guy matthew shepherd (quebec) rhapsodic.org j$ (right) Henriette's Herbal Blog fanatical apathy lynne ydw i iconophobia slumbering lungfish
geek Y!Cool Thing michael j radwin jeremy z
(The Official Website of the Internet)
dave's picks ultramookie Josh Woodward derek balling j$ (left) simon willison Yahoo! Search Blog
news ars technica search engine watch webmaster world.com
forums uh.net man-man killroy & tina

experimental

Firefox search plugins for Yahoo!

My Living Room media box config

The Official "Official" Registry of the Internet

Powered by WordPress
Hosted on Dreamhost.