:: Forum >>

XML Problem

Hi,
I need to parse the following XML to a grid to populate the xml values (Primary, Secondary etc) as Grid column headers.

<contacts>
<bus_contact0>Primary</bus_contact0>
<bus_contact1>Secondary</bus_contact1>
<bus_contact2>After Hours</bus_contact2>
<bus_contact3>Escalation</bus_contact3>
<tech_contact0>Primary</tech_contact0>
<tech_contact1>Secondary</tech_contact1>
<tech_contact2>After Hours</tech_contact2>
<tech_contact3>Escalation</tech_contact3>
</contacts>

device.setId('DataGrid');// device is the grid object

var table = new AW.XML.Table;
table.setAsync(false);
var str = '/cgi-bin/contacts_report.cgi';
table.setURL(str);
var table_response = table.response;
table.response = function(xml) {
table_response.call(this, xml);
alert(xml);//atleast I want to see the xml being parsed, so that I can make it to display as grid column header. But when I issue an alert statement, it shows blank(object).
get_data(device,table, 8);
}
table.request();

function get_data(field, xml,col){
var row = 0;
var cnt = 0;
alert(xml.getCount()); //prints 8, correct;
for (var i=0; i< xml.getCount(); i++){
alert(xml.getData(0, i));//prints nothing
field.setColumnCount(xml.getCount());
field.setHeaderText(xml.getData(0, i));
}
}

Can anyone please help me? I searched for similar issues, but to my bad luck could not find.

Thanks
Vijay
Vijay
Monday, January 7, 2008
The xml argument in table.response(xml) is a DOMDocument object so you should be able to navigate to DOM node using XML DOM API.
Alex (ActiveWidgets)
Tuesday, January 8, 2008
Thanks a lot Alex for your quick response. Yes, that solved the issue. It seems each xml tag returned in response is interpreted as each row, rather than each column. I had to include another loop (with xml.getData() to convert to one row of header data.

Thanks again!
Vijay
Tuesday, January 8, 2008
Could you perhaps put your updated code here as well?
AcidRaZor
Wednesday, January 9, 2008

This topic is archived.


Back to support forum

Forum search