View Full Version : Loading XML data into data.Store into a ComboBox

13 Jul 2009, 4:09 PM
I appreciate any help on why I'm not getting the data into the ComboBox?

when I use a static xml file it works fine, but when I use a php file that returns xml it doesn't even though I'm using header('Content-type: text/xml'); ... any suggestion please ?

PHP file: agent.php

header('Content-type: text/xml');
echo "
<?xml version="1.0" encoding="UTF-8"?>
<agentinfo> - 10560</agentinfo>
<agentinfo> - 10565</agentinfo>
Javascript file: agents.js


var agentsStore = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: 'agent.php'}),
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Agent" tag
record: 'Agent'
}, [
'agentid', 'agentinfo'


var win = new Ext.Window({
baseCls: '',
layout: 'form',
bodyStyle:'padding:10px 5px 10px 10px',
labelWidth: 110,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'IP address / Name',
name: 'host',
allowBlank: false
}, new Ext.form.ComboBox({
fieldLabel: 'Select Agent',
name: 'int_agent',
mode: 'local',
loadingText:"Loading Agents",
store: agentsStore,
valueField: 'agentid',
displayField: 'agentinfo'

14 Jul 2009, 10:10 AM
this is fixed by changing this line of php

echo "
<?xml version='1.0' encoding='UTF-8'?>
to remove the newline before <?xml :

echo "<?xml version='1.0' encoding='UTF-8'?>

14 Jul 2009, 11:34 AM
2 time wrong colons:

echo '<?xml version="1.0" encoding="UTF-8"?> ... ';