XML Parsing

Aug 31 2011 12:04 PM AUG 31 2011 12:04 PM
Speeding Up Your SiteHTML | Javascript | XML

So you have a website and that site gets millions of hits per day. Either you are running a silly static site that you manually update or you have some intense CMS that caches using all sorts of methods.

XML happens to be one of the biggest tools of the trade.

You might ask, "Why should I cache and not read directly from the database?" Well performing heavy queries to gather data thousands of times per minute is enough to strain even the best of servers.

Twitter does it! Thats twitter they have server farms and heavy massive load balancers you name it and they probably do have some level of caching.

Think smart not harder. XML is a powerful way to sort, manage and handle cached data. It can be read by all kinds of languages. PHP has a wonderful built in function called SimpleXML. It allows you to handle it as an object and iterate through its information fast and easy. PHP.net SimpleXML.

Javascript has its own methods generally these are per browser and each may have slight variations to this. Here is an article I found that talks about the basics of reading XML with javascript. www.hiteshagrawal.com

In general its a fast and well supported language. Generally speaking "ITS HTML!"

What about JSON? Well JSON is a great fast way to communicate and pull data from a database or server side call. However, it does lack in sortability. I prefer JSON when dealing with smaller pieces of data ex: Sending/Recieving smaller changes from a database. Sending being an update/insert that needs to be made to a database. Receving such as when I need to pull a smaller piece of information from the server. Its similar handlings in regard to object based that allows for a fairly large range of handlings with it.

In general this is like compairing apples to oranges they both have somethings they are good at and somethings they are terrible at. One instance of this is that XML is not javascript based but browser based. This could and can cause conflicts as if each browser handles it differently exceptions will have to be placed to handle each case.

An interesting article with an interesting argument + tons more articles on this subject: ajaxian.com