xml parsing - IndexedDB DB Datas To XML -
in project, have create xml file indexeddb datas. passing xml file webservice save datas server.. , in return, want read , parse xml file (or data) sent webservice.. give me suggestions..
idb "object stores" can store javascript objects. save xml data idb database you'll need transform xml object javascript object. function depend on xml needs - there's no one-size-fits-all approach xml transformation.
in general, follow advice laid out here in translating xml objects json representation:
for example, if sql table looked this:
+------+--------+--------+ | | cola | colb | +------+--------+--------+ | row1 | cella1 | cellb1 | | row2 | cella2 | cellb2 | | row3 | cella3 | cellb3 | +------+--------+--------+
your javascript object may this:
var myobjecttostore = { 'row1': { 'cola': 'cella1', 'colb': 'cellb1' }, 'row2': { 'cola': 'cella2', 'colb': 'cellb2' }, 'row3': { 'cola': 'cella3', 'colb': 'cellb3' } };
the json representation of object similar:
{ "row1": { "cola": "cella1", "colb": "cellb1" }, "row2": { "cola": "cella2", "colb": "cellb2" }, "row3": { "cola": "cella3", "colb": "cellb3" } }
it's far easier use javascript objects without such serialization. highly suggest exploring using json on network rather xml.
modern browsers support json.parse()
, json.stringify
, web servers can handle application/json
mimetype.
Comments
Post a Comment