I have found no magic bullet to convert XML to JSON.
I started building an Ajax project where I was serving my data as XML
and ran into the same IE vs Firefox problems. After bashing my head
against the wall for a few days I gave up on using Prototype to fetch
my XML and did it the old fashioned way:
if (document.implementation && document.implementation.createDocument)
{
var parser=new DOMParser();
xmlDoc=parser.parseFromString('',"text/xml");
xmlDoc.load('data.xml');
x=setTimeout('loadForm()',500)
//pray that the xml loads in 500 ms.
//loadForm() is my function to parse the XML
}
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) loadForm()
};
xmlDoc.load('data.xml');
}
Because that was a really ugly solution, I decided to scrap the XML
method and re-wrote my server code to spit out JSON instead. It was
elegant, my client code was smaller, faster and easier to read. I'm
never going back to XML.
On Dec 28, 2:58 pm, Tobie Langel <[EMAIL PROTECTED]> wrote:
> http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
>
> http://www.thomasfrank.se/xml_to_json.html
>
> Haven't tested either.
>
> On Dec 28, 5:28 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Or even better. You tell me a the client lib you use to parse a xml
> > from a url to JSON, I immediately stick to JSON without hesitating...
>
> > ;-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---