Im fairly new to javascript but I am an experianced php programmer. I have been parsing XML information using php, but my CPU usage has been too high recently due to this.
I am trying to convert my scripts to javascript, but I am unsure how I can do this using javascript. I think that if I get started off, the rest will be easy.
Parsing this XML document depends on how you intend to access it. You can’t do it via Ajax because the XML file is on a different domain (I doubt you are going to be doing this from the audioscrobbler.com domain). So since you’d have to grab the XML on the server side, you might as well process it there too.
Technically you could access the XML via a hidden iframe but it’s not what I’d consider a “clean” solution.
Well then I would recommend doing it all with PHP! PHP has lots of XML parsing functions - head over to http://php.net and look up the XML functions. It even has DOMDocument which allows you to parse it much like you would parse a normal HTML or XML DOM via javascript.
But, if for whatever reason you have to do it with JS, you would just launch a simple XMLHttpRequest for the XML file and then parse it, using responseXML (not responseText). If you don’t know what that means, look for any simple Ajax tutorial and follow it - there are probably thousands of Ajax tutorials out there.