PDA

View Full Version : XmlReader does not work with a single record.



margozzi
27 Dec 2010, 3:00 PM
var reader = new Ext.data.XmlReader( {
record: 'Data'
}, ['Foo', 'Bar']
);

With this data coming back from Web Service, the XmlReader fails to read it correctly.

<Data>
<Foo>23</Foo>
<Bar>76</Bar>
</Data

The very same reader is happy with this format of Data though.

<Response>
<Data>
<Foo>23</Foo>
<Bar>76</Bar>
</Data
</Response>

All of the examples I have seen like to wrap the data with success type
information. This is superfluous when using RESTful web services. The
success is determined by the HTTP status code. So I don't see the need
for it again in the XML data.

Is there a way to make this work in the first scenario?

Condor
28 Dec 2010, 1:14 AM
Use:

record: '/'
(your record is the XML root and not an element inside the root)

margozzi
28 Dec 2010, 8:38 AM
That worked. Thanks. I was unable to figure that out from the docs. I am very pleased that there is such a simple solution.