Skip to main content

Posts

Showing posts with the label jquery

Using jQuery to parse an xml feed and create a bullet list

This one's really simple, but I end up using it a lot so why not post it? Say you need to display an xml news feed on a site. I needed to. So I looked at how to do it with PHP, and it seemed far more over-complicated than need be for something so simple. One again jQuery comes to the rescue. If you're not familiar with jQuery, it's a javascript library that makes javascript actually pleasant to use. I used to avoid javascript because of cross-browser issues, and everything always seemed more difficult than it needed to be. jQuery fixes all that. The code snippet below uses jQuery to grab the XML feed, go through each item in the feed and output a simple bullet list of linked titles. Should be easy to adapt it to whatever your needs may be. Just be sure you also have the jQuery library set up on what page you use it on. It also uses a <ul id="theBox"> to put the bullet items in. $(document).ready(function(){ var theBox = ""; $.get('XML URL...

jQuery rocks

OK, I'm late to the game on it, but I'm really digging jQuery. I used to really dread having to do much of anything in javascript because of all the retarded cross-browser issues, the difficulty testing, etc. But jQuery is really turning that around for me - you can get some really neat stuff without having to deal with all the usual javascript stupidity (well, most of it) - check it out !