Sorry this is a code submit, I didn’t know where to send it.
I’ve implemented the function to convert the event xml into js object by taking care of subnodes like in this example.
<data>
<event id="497649">
<text>Pepperminta</text>
<start_date>2010-08-09 21:30:00</start_date>
<block_min>94</block_min>
<end_date>2010-08-09 23:04:00</end_date>
<venue_id>6</venue_id>
<films>
<film>
<min>10</min>
<title>Introduction</title>
</film>
<film>
<min>84</min>
<title>Pepperminta</title>
</film>
</films>
<section_id>10</section_id>
</event>
</data>
[code]
scheduler.xmlNodeToJSON = function(xml) {
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
for (var i=0; i<xml.attributes.length; i++)
obj[xml.attributes[i].name]=xml.attributes[i].value;
} else if (xml.nodeType == 3) { // text
obj = xml.nodeValue;
}
// do children
if (xml.hasChildNodes()) {
for(var i = 0; i < xml.childNodes.length; i++) {
var nn = xml.childNodes[i].nodeName;
if (typeof(obj[nn]) == 'undefined') {
if(nn == '#text'){
var txt = trim(""+this.xmlNodeToJSON(xml.childNodes[i]));
if(txt.length>0){
obj = txt;
}
}else{
obj[nn] = this.xmlNodeToJSON(xml.childNodes[i]);
}
} else {
if (typeof(obj[nn].length) == 'undefined') {
var old = obj[nn];
obj[nn] = [];
obj[nn].push(old);
}
if (typeof(obj[nn])=='object') {
obj[nn].push(this.xmlNodeToJSON(xml.childNodes[i]));
}
}
}
}
return obj;
}[/code]