views:

354

answers:

3

I have a database at zoho creator. They feed me a json of the database content. I have trouble to parse and display that data with jquery or php or in html

Question : So how do I capture json data, and save (convert) it to file as XML. With the xml file I can parse it with jquery xpath easily... the "file" will be a local database, as a backup (if saved)

anybod have clue on that ?


as request.. here is the link for the query -link-

getting a way to display data from var i need is the minimum i must have ! like prod_categorie or prod_nom

note :

  1. i can get help with any tutorial on how to get xml data from zoho
  2. any json to xml converter (jquery) out there ?????
+2  A: 

Firstly, Javascript has no file-output capability. The best it can do is send data back to a server for processing there -- so the "capture json data, and save it to file as XML" idea is out.

What problems in particular are you having with using JSON? As it gets converted to a native Javascript object, I find it quite easy to work with myself. Though, I can see that if you wanted to use XPath to query it, JSON is no help. You should still be able to get to whatever data you need, but it might be a bit more verbose.

In your example JSON:

{"Liste_des_produits1":[{"Added_Time":"28-Sep-2009 16:35:03",
"prod_ingredient":"sgsdgds","prod_danger":["sans danger pour xyz"],"prod_odeur"..

You could access the prod_danger property like this:

$.getJSON(url, function(data) {
   var danger = data.List_des_produits1[0].prod_danger; 
});

If you are having trouble getting the right path to a property, Firebug is a great help with this. Just call this:

$.getJSON(url, function(data) {
    console.log(data);
});

...and then you can browse through its properties in a tree-structure.

nickf
i have try that little bit of code just to get and error could not parse url... what wrong ? var $myurl = "http://creator.zoho.com/marcandremenard/application-lemieux/view-embed/Liste_produits_View1/7GWhjVxYeNDePjPZnExCKy58Aqr21JX2hJEE6fAfgfkapEQnRjRd5RUy8wdjKuhmFEhJR9QRsBCUBjACAdSgmJNQSvxMt6geaMNC/";$.getJSON($myurl, function(data) { var danger = data.List_des_produits1[0].prod_danger; console.log(data); alert(danger);});</script>
marc-andre menard
this link is better, but still error 1012... http://creatorexport.zoho.com/marcandremenard/application-lemieux/json/Liste_produits_View1/zm69NgTxUvjGFw9MGRBfWBzpZVrrB2DUCEr5Yu2nr2vhe6fQC3ktyCbNXy5q17r2U0vZGQQ7y0zCODpOJvQY9ydw12bS7aDabsAk/
marc-andre menard
is it on the save server (domain and subdomain) as your page? If not, then access to the file is blocked by Javascript for security reasons. You'll have to use [JSONP](http://remysharp.com/2007/10/08/what-is-jsonp/) to access the data in this case.
nickf
+1  A: 
system PAUSE
+2  A: 

There are jQuery pluggins for such convertion, for example json2xml.

emkee