3.2.0

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
January 7,
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)
January 8,
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
January 8,
Could you perhaps put your updated code here as well?
AcidRaZor
January 9,

This topic is archived.

See also:


Back to support forum