Friday, November 24, 2006

SimpleXML for JavaScript

I really did not realise that its been two months since I last posted anything. A lot has happened in the past two months, actually quite a lot has happened and I guess I never seem to get the time to update this blog. But then again like I've said in the last two posts, I will try and post on a regular basis. I had developed a SimpleXML library in JavaScript  but never got the time to post a link on this blog. Its hosted on http://code.google.com. I made it like a month back but due to work I've not been able to release it. Its a very important piece of software that I have developed but since there is no documentation its really hard to release it.

Anyhow if you've used SimpleXML in php its the exact same thing for JavaScript. You can view the code or download it using SVN. There are three simple functions.

simplexml_import_dom(dom);
simplexml_load_string(string);
simplexml_load_file(filename, callback);

  1. simplexml_import_dom(dom): takes a dom element and returns a SimpleXML object
  2. simplexml_load_string(string): takes xml as string and returns a SimpleXML object.
  3. simplexml_load_file(filename, callback): takes two parameters, first the url of XML file, and the name of the callback function, which will ba called once the file has been loaded.

There is a sample index.html that will give you a rough idea of how to use the library. I will try and give a little more detail and a few samples as and when I get a little more time.

No comments: