PDA

View Full Version : parse xml file



Manouchehr_Amini
9 Feb 2011, 8:39 AM
Hi,

I am trying to parse an xml file (see the end of this text)using xmlreader and show the results in a grid.This is a piece of code i use:
var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({ url: 'xxxx.xml' }),
reader: new Ext.data.XmlReader({
record: 'sld:ColorMapEntry ',
totalRecords: 'result'
}, [
{name: 'Color', type: 'string', mapping:'@color' },
{name: 'Opacity', type:'float', mapping:'@opacity' },
{name: 'Value', type: 'float', mapping:'@quantity' }
])
});
ds.load();
var grid = new Ext.grid.GridPanel({
store: ds,
columns: [
{ header: "Color", width: 120, dataIndex: 'color', sortable: true },
{ header: "Opacity", width: 180, dataIndex: 'opacity', sortable: true }

],
renderTo: 'mygrid',
width: 540,
height: 200
});
What I get is an empty grid.
Any help?
Thanks


//**
<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<sld:Name>map0m</sld:Name>
<sld:Title>map0m</sld:Title>
<sld:FeatureTypeStyle>
<sld:Name>map0m</sld:Name>
<sld:FeatureTypeName>Feature</sld:FeatureTypeName>
<sld:Rule>
<sld:RasterSymbolizer>
<sld:Geometry>
<ogc:PropertyName>geom</ogc:PropertyName>
</sld:Geometry>
<sld:OverlapBehavior>
<sld:null/>
</sld:OverlapBehavior>
<sld:ColorMap color="#FFFFFF" opacity="0" quantity="-9999">
<sld:ColorMapEntry color="#FFFFFF" opacity="0" quantity="-9999"/>
<sld:ColorMapEntry color="#A9F5A9" opacity="0.5" quantity="1"/>
<sld:ColorMapEntry color="#FA5858" opacity="0.5" quantity="7"/>
</sld:ColorMap>
<sld:ShadedRelief>
<sld:BrightnessOnly>false</sld:BrightnessOnly>
</sld:ShadedRelief>
</sld:RasterSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>

//**