3.2.0

Loading XML data from a string var

Hi,

I try to find a way to load XML data into the grid. The xml data is stored in a string. Some function like loadXML(string) would be useful.
My page already retrieves data from the server thru a HTTP request. I extract the data for the grid from this data.
Can somebody help me with this?

Henk
Henk
April 6,
I am going to add setXML/getXML methods to the table class. For now you can try table.response(xml) which expects DOMDocument object.
Alex (ActiveWidgets)
April 6,

table._ready = true;
table.response(xml)
April 7,
Thanks, this works fine.
April 7,
I would like to load data from a database say RDBMS into the table.
Any help would be appreciated

Thanks
mendi
April 10,
Hi,

I'm new to this toolkit and v. excited by the potential...

I am creating an XML DOMDocument object from my database and trying to load this into a grid. I am hoping to avoid writing out to a XML island in the html.

Alex, your earlier post in this thread says "try table.response(xml)" - I'd be grateful if you could expand on this a bit, i.e. where this goes perhaps with reference to one of your package exampes e.g. xml - dataset ( I haven't yet studied the methods etc.. of your table class).

I see you've mentioned a couple of times that a setXML/getXML should be added soon, but I guess I'm impatient to try and see how this all works together!

I also haven't been working with XML long, so apologies if this is trivial.
Also I note that this is quite an old thread, but I haven't seen this expained elsewhere in more detail - maybe I missed it?

Thanks a lot.
Will
September 23,
Hi,

You can parse the XML yourself like example. The example does a XML read out of Excel in Excel I have made VBA script making XML. This skips all kind of problems.
I have also code that makes a jscript file out of VBA that fills in the array (skip XML parsing).

clentityviewer.prototype.processxml = function (cfile) {
if (this.fillgrid) { // data loaded in js default.js was loaded properly otherwise we use XML loading (slower)
this.fillgrid ();
} else {
var oparsed = parsexmluri (cfile); // parsexmluri general routine in openmodeling
var lheader = false;
var nlenrow, ncelllen, ocells, orow, ogridrow, nrowlength, xmldoc, nlenrow, ncollen, csex;
if (oparsed[1]) {
alert ("XML errors " + oparsed[1] );
} else { // fill the grid
xmldoc = oparsed [0];
orows = xmldoc.getElementsByTagName ("r");
nrowlength = orows.length;
for (var i=0;i<nrowlength;i++) {
orow = orows [i];
ogridrow = null;
if (orow.hasChildNodes () && !lheader) { // we have a filled row and its the first one
// in the first row we take the tagnames as haeader
ocells = orow.childNodes;
ncelllen = ocells.length;
for (var j=0;j<ncelllen;j++) if (ocells.item (j).nodeType == 1) this.columns.push ( ocells.item (j).tagName );
lheader = true;
ncollen = this.columns.length;
}
if (orow.hasChildNodes ()) {
ogridrow = [];
ocells = orow.childNodes;
ncelllen = ocells.length;
for (var j=0;j<ncelllen;j++) {
if (ocells.item (j).nodeType == 1) {
/* if (this.columns [ogridrow.length] == "Geslacht") { // take care when changing header names !
csex = textnode (ocells.item (j)).toUpperCase ();
if (csex != "") {
if (csex == "V") {
ogridrow.push ( "<img src=\"../images/female.gif\" height='13px' />");
} else {
ogridrow.push ( "<img src=\"../images/male.gif\"/ height='13px'>");
}
} else {
ogridrow.push ( "");
}
} else if (this.columns [ogridrow.length] == "Mobiel") { // take care when cnanging header names !
//ogridrow.push ( "<img src=\"../images/cellphone.gif\" height='13px' /> " + textnode (ocells.item (j)) );
(textnode (ocells.item (j)) != "") ? (ogridrow.push ( "<img src=\"../images/cellphone.gif\" height='13px' /> " + textnode (ocells.item (j)) )) : (ogridrow.push (""));
} else {
ogridrow.push ( textnode (ocells.item (j)) );
} */
}
}
nlenrow = ogridrow.length;
for (var j=nlenrow;j<ncollen;j++) ogridrow.push (""); // make sure every row has the same length
}
if (ogridrow) { // filled row?
this.mydata.push (ogridrow);
}
}
}
}
}
September 23,
Very Good!!.
Pedram
October 2,

This topic is archived.

See also:


Back to support forum