Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / output / Ext.data.reader.Xml.js
1 Ext.data.JsonP.Ext_data_reader_Xml({
2   "tagname": "class",
3   "name": "Ext.data.reader.Xml",
4   "doc": "<p>The XML Reader is used by a Proxy to read a server response that is sent back in XML format. This usually\nhappens as a result of loading a Store - for example we might create something like this:</p>\n\n\n\n\n<pre><code>Ext.define('User', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'email']\n});\n\nvar store = new Ext.data.Store({\n    model: 'User',\n    proxy: {\n        type: 'ajax',\n        url : 'users.xml',\n        reader: {\n            type: 'xml',\n            record: 'user'\n        }\n    }\n});\n</code></pre>\n\n\n\n\n<p>The example above creates a 'User' model. Models are explained in the <a href=\"#/api/Ext.data.Model\" rel=\"Ext.data.Model\" class=\"docClass\">Model</a> docs if you're\nnot already familiar with them.</p>\n\n\n\n\n<p>We created the simplest type of XML Reader possible by simply telling our <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a>'s \n<a href=\"#/api/Ext.data.proxy.Proxy\" rel=\"Ext.data.proxy.Proxy\" class=\"docClass\">Proxy</a> that we want a XML Reader. The Store automatically passes the configured model to the\nStore, so it is as if we passed this instead:\n\n<pre><code>reader: {\n    type : 'xml',\n    model: 'User',\n    record: 'user'\n}\n</code></pre>\n\n<p>The reader we set up is ready to read data from our server - at the moment it will accept a response like this:</p>\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;user&gt;\n    &lt;id&gt;1&lt;/id&gt;\n    &lt;name&gt;Ed Spencer&lt;/name&gt;\n    &lt;email&gt;ed@sencha.com&lt;/email&gt;\n&lt;/user&gt;\n&lt;user&gt;\n    &lt;id&gt;2&lt;/id&gt;\n    &lt;name&gt;Abe Elias&lt;/name&gt;\n    &lt;email&gt;abe@sencha.com&lt;/email&gt;\n&lt;/user&gt;\n</code></pre>\n\n<p>The XML Reader uses the configured <a href=\"#/api/Ext.data.reader.Xml-cfg-record\" rel=\"Ext.data.reader.Xml-cfg-record\" class=\"docClass\">record</a> option to pull out the data for each record - in this case we\nset record to 'user', so each &lt;user&gt; above will be converted into a User model.</p>\n\n<p><u>Reading other XML formats</u></p>\n\n<p>If you already have your XML format defined and it doesn't look quite like what we have above, you can usually\npass XmlReader a couple of configuration options to make it parse your format. For example, we can use the \n<a href=\"#/api/Ext.data.reader.Xml-cfg-root\" rel=\"Ext.data.reader.Xml-cfg-root\" class=\"docClass\">root</a> configuration to parse data that comes back like this:</p>\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;users&gt;\n    &lt;user&gt;\n        &lt;id&gt;1&lt;/id&gt;\n        &lt;name&gt;Ed Spencer&lt;/name&gt;\n        &lt;email&gt;ed@sencha.com&lt;/email&gt;\n    &lt;/user&gt;\n    &lt;user&gt;\n        &lt;id&gt;2&lt;/id&gt;\n        &lt;name&gt;Abe Elias&lt;/name&gt;\n        &lt;email&gt;abe@sencha.com&lt;/email&gt;\n    &lt;/user&gt;\n&lt;/users&gt;\n</code></pre>\n\n<p>To parse this we just pass in a <a href=\"#/api/Ext.data.reader.Xml-cfg-root\" rel=\"Ext.data.reader.Xml-cfg-root\" class=\"docClass\">root</a> configuration that matches the 'users' above:</p>\n\n<pre><code>reader: {\n    type  : 'xml',\n    root  : 'users',\n    record: 'user'\n}\n</code></pre>\n\n<p>Note that XmlReader doesn't care whether your <a href=\"#/api/Ext.data.reader.Xml-cfg-root\" rel=\"Ext.data.reader.Xml-cfg-root\" class=\"docClass\">root</a> and <a href=\"#/api/Ext.data.reader.Xml-cfg-record\" rel=\"Ext.data.reader.Xml-cfg-record\" class=\"docClass\">record</a> elements are nested deep inside\na larger structure, so a response like this will still work:\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;deeply&gt;\n    &lt;nested&gt;\n        &lt;xml&gt;\n            &lt;users&gt;\n                &lt;user&gt;\n                    &lt;id&gt;1&lt;/id&gt;\n                    &lt;name&gt;Ed Spencer&lt;/name&gt;\n                    &lt;email&gt;ed@sencha.com&lt;/email&gt;\n                &lt;/user&gt;\n                &lt;user&gt;\n                    &lt;id&gt;2&lt;/id&gt;\n                    &lt;name&gt;Abe Elias&lt;/name&gt;\n                    &lt;email&gt;abe@sencha.com&lt;/email&gt;\n                &lt;/user&gt;\n            &lt;/users&gt;\n        &lt;/xml&gt;\n    &lt;/nested&gt;\n&lt;/deeply&gt;\n</code></pre>\n\n<p><u>Response metadata</u></p>\n\n<p>The server can return additional data in its response, such as the <a href=\"#/api/Ext.data.reader.Xml-cfg-totalProperty\" rel=\"Ext.data.reader.Xml-cfg-totalProperty\" class=\"docClass\">total number of records</a> \nand the <a href=\"#/api/Ext.data.reader.Xml-cfg-successProperty\" rel=\"Ext.data.reader.Xml-cfg-successProperty\" class=\"docClass\">success status of the response</a>. These are typically included in the XML response\nlike this:</p>\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;total&gt;100&lt;/total&gt;\n&lt;success&gt;true&lt;/success&gt;\n&lt;users&gt;\n    &lt;user&gt;\n        &lt;id&gt;1&lt;/id&gt;\n        &lt;name&gt;Ed Spencer&lt;/name&gt;\n        &lt;email&gt;ed@sencha.com&lt;/email&gt;\n    &lt;/user&gt;\n    &lt;user&gt;\n        &lt;id&gt;2&lt;/id&gt;\n        &lt;name&gt;Abe Elias&lt;/name&gt;\n        &lt;email&gt;abe@sencha.com&lt;/email&gt;\n    &lt;/user&gt;\n&lt;/users&gt;\n</code></pre>\n\n<p>If these properties are present in the XML response they can be parsed out by the XmlReader and used by the\nStore that loaded it. We can set up the names of these properties by specifying a final pair of configuration \noptions:</p>\n\n<pre><code>reader: {\n    type: 'xml',\n    root: 'users',\n    totalProperty  : 'total',\n    successProperty: 'success'\n}\n</code></pre>\n\n<p>These final options are not necessary to make the Reader work, but can be useful when the server needs to report\nan error or if it needs to indicate that there is a lot of data available of which only a subset is currently being\nreturned.</p>\n\n<p><u>Response format</u></p>\n\n<p><b>Note:</b> in order for the browser to parse a returned XML document, the Content-Type header in the HTTP \nresponse must be set to \"text/xml\" or \"application/xml\". This is very important - the XmlReader will not\nwork correctly otherwise.</p>\n\n",
5   "extends": "Ext.data.reader.Reader",
6   "mixins": [
7
8   ],
9   "alternateClassNames": [
10     "Ext.data.XmlReader"
11   ],
12   "xtype": null,
13   "author": "Ed Spencer",
14   "docauthor": null,
15   "singleton": false,
16   "private": false,
17   "cfg": [
18     {
19       "tagname": "cfg",
20       "name": "idProperty",
21       "member": "Ext.data.reader.Reader",
22       "type": "String",
23       "doc": "<p>Name of the property within a row object\nthat contains a record identifier value.  Defaults to <tt>The id of the model</tt>.\nIf an idProperty is explicitly specified it will override that of the one specified\non the model</p>\n",
24       "private": false,
25       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
26       "linenr": 153,
27       "html_filename": "Reader.html",
28       "href": "Reader.html#Ext-data-reader-Reader-cfg-idProperty",
29       "shortDoc": "Name of the property within a row object\nthat contains a record identifier value.  Defaults to The id of the model.\nI..."
30     },
31     {
32       "tagname": "cfg",
33       "name": "implicitIncludes",
34       "member": "Ext.data.reader.Reader",
35       "type": "Boolean",
36       "doc": "<p>True to automatically parse models nested within other models in a response\nobject. See the <a href=\"#/api/Ext.data.reader.Reader\" rel=\"Ext.data.reader.Reader\" class=\"docClass\">Ext.data.reader.Reader</a> intro docs for full explanation. Defaults to true.</p>\n",
37       "private": false,
38       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
39       "linenr": 190,
40       "html_filename": "Reader.html",
41       "href": "Reader.html#Ext-data-reader-Reader-cfg-implicitIncludes",
42       "shortDoc": "True to automatically parse models nested within other models in a response\nobject. See the Ext.data.reader.Reader in..."
43     },
44     {
45       "tagname": "cfg",
46       "name": "messageProperty",
47       "member": "Ext.data.reader.Reader",
48       "type": "String",
49       "doc": "<p>The name of the property which contains a response message.\nThis property is optional.</p>\n",
50       "private": false,
51       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
52       "linenr": 185,
53       "html_filename": "Reader.html",
54       "href": "Reader.html#Ext-data-reader-Reader-cfg-messageProperty"
55     },
56     {
57       "tagname": "cfg",
58       "name": "record",
59       "member": "Ext.data.reader.Xml",
60       "type": "String",
61       "doc": "<p>The DomQuery path to the repeated element which contains record information.</p>\n",
62       "private": false,
63       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Xml.js",
64       "linenr": 171,
65       "html_filename": "Xml.html",
66       "href": "Xml.html#Ext-data-reader-Xml-cfg-record"
67     },
68     {
69       "tagname": "cfg",
70       "name": "root",
71       "member": "Ext.data.reader.Reader",
72       "type": "String",
73       "doc": "<p><b>Required</b>.  The name of the property\nwhich contains the Array of row objects.  Defaults to <tt>undefined</tt>.\nAn exception will be thrown if the root property is undefined. The data\npacket value for this property should be an empty array to clear the data\nor show no data.</p>\n",
74       "private": false,
75       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
76       "linenr": 176,
77       "html_filename": "Reader.html",
78       "href": "Reader.html#Ext-data-reader-Reader-cfg-root",
79       "shortDoc": "Required.  The name of the property\nwhich contains the Array of row objects.  Defaults to undefined.\nAn exception wil..."
80     },
81     {
82       "tagname": "cfg",
83       "name": "successProperty",
84       "member": "Ext.data.reader.Reader",
85       "type": "String",
86       "doc": "<p>Name of the property from which to\nretrieve the success attribute. Defaults to <tt>success</tt>.  See\n<a href=\"#/api/Ext.data.proxy.Proxy\" rel=\"Ext.data.proxy.Proxy\" class=\"docClass\">Ext.data.proxy.Proxy</a>.<a href=\"#/api/Ext.data.proxy.Proxy--exception\" rel=\"Ext.data.proxy.Proxy--exception\" class=\"docClass\">exception</a>\nfor additional information.</p>\n",
87       "private": false,
88       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
89       "linenr": 168,
90       "html_filename": "Reader.html",
91       "href": "Reader.html#Ext-data-reader-Reader-cfg-successProperty",
92       "shortDoc": "Name of the property from which to\nretrieve the success attribute. Defaults to success.  See\nExt.data.proxy.Proxy.exc..."
93     },
94     {
95       "tagname": "cfg",
96       "name": "totalProperty",
97       "member": "Ext.data.reader.Reader",
98       "type": "String",
99       "doc": "<p>Name of the property from which to\nretrieve the total number of records in the dataset. This is only needed\nif the whole dataset is not passed in one go, but is being paged from\nthe remote server.  Defaults to <tt>total</tt>.</p>\n",
100       "private": false,
101       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
102       "linenr": 160,
103       "html_filename": "Reader.html",
104       "href": "Reader.html#Ext-data-reader-Reader-cfg-totalProperty",
105       "shortDoc": "Name of the property from which to\nretrieve the total number of records in the dataset. This is only needed\nif the wh..."
106     }
107   ],
108   "method": [
109     {
110       "tagname": "method",
111       "name": "Xml",
112       "member": "Ext.data.reader.Reader",
113       "doc": "\n",
114       "params": [
115         {
116           "type": "Object",
117           "name": "config",
118           "doc": "<p>Optional config object</p>\n",
119           "optional": false
120         }
121       ],
122       "return": {
123         "type": "void",
124         "doc": "\n"
125       },
126       "private": false,
127       "static": false,
128       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
129       "linenr": 1,
130       "html_filename": "Reader.html",
131       "href": "Reader.html#Ext-data-reader-Reader-method-constructor",
132       "shortDoc": "\n"
133     },
134     {
135       "tagname": "method",
136       "name": "getData",
137       "member": "Ext.data.reader.Xml",
138       "doc": "<p>Normalizes the data object</p>\n",
139       "params": [
140         {
141           "type": "Object",
142           "name": "data",
143           "doc": "<p>The raw data object</p>\n",
144           "optional": false
145         }
146       ],
147       "return": {
148         "type": "Object",
149         "doc": "<p>Returns the documentElement property of the data object if present, or the same object if not</p>\n"
150       },
151       "private": false,
152       "static": false,
153       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Xml.js",
154       "linenr": 225,
155       "html_filename": "Xml.html",
156       "href": "Xml.html#Ext-data-reader-Xml-method-getData",
157       "shortDoc": "<p>Normalizes the data object</p>\n"
158     },
159     {
160       "tagname": "method",
161       "name": "getResponseData",
162       "member": "Ext.data.reader.Reader",
163       "doc": "<p>Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemented by each subclass</p>\n",
164       "params": [
165         {
166           "type": "Object",
167           "name": "response",
168           "doc": "<p>The responce object</p>\n",
169           "optional": false
170         }
171       ],
172       "return": {
173         "type": "Object",
174         "doc": "<p>The useful data from the response</p>\n"
175       },
176       "private": false,
177       "static": false,
178       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
179       "linenr": 458,
180       "html_filename": "Reader.html",
181       "href": "Reader.html#Ext-data-reader-Reader-method-getResponseData",
182       "shortDoc": "Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemen..."
183     },
184     {
185       "tagname": "method",
186       "name": "read",
187       "member": "Ext.data.reader.Reader",
188       "doc": "<p>Reads the given response object. This method normalizes the different types of response object that may be passed\nto it, before handing off the reading of records to the <a href=\"#/api/Ext.data.reader.Xml-method-readRecords\" rel=\"Ext.data.reader.Xml-method-readRecords\" class=\"docClass\">readRecords</a> function.</p>\n",
189       "params": [
190         {
191           "type": "Object",
192           "name": "response",
193           "doc": "<p>The response object. This may be either an XMLHttpRequest object or a plain JS object</p>\n",
194           "optional": false
195         }
196       ],
197       "return": {
198         "type": "Ext.data.ResultSet",
199         "doc": "<p>The parsed ResultSet object</p>\n"
200       },
201       "private": false,
202       "static": false,
203       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
204       "linenr": 226,
205       "html_filename": "Reader.html",
206       "href": "Reader.html#Ext-data-reader-Reader-method-read",
207       "shortDoc": "Reads the given response object. This method normalizes the different types of response object that may be passed\nto ..."
208     },
209     {
210       "tagname": "method",
211       "name": "readRecords",
212       "member": "Ext.data.reader.Xml",
213       "doc": "<p>Parses an XML document and returns a ResultSet containing the model instances</p>\n",
214       "params": [
215         {
216           "type": "Object",
217           "name": "doc",
218           "doc": "<p>Parsed XML document</p>\n",
219           "optional": false
220         }
221       ],
222       "return": {
223         "type": "Ext.data.ResultSet",
224         "doc": "<p>The parsed result set</p>\n"
225       },
226       "private": false,
227       "static": false,
228       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Xml.js",
229       "linenr": 288,
230       "html_filename": "Xml.html",
231       "href": "Xml.html#Ext-data-reader-Xml-method-readRecords",
232       "shortDoc": "<p>Parses an XML document and returns a ResultSet containing the model instances</p>\n"
233     }
234   ],
235   "property": [
236     {
237       "tagname": "property",
238       "name": "rawData",
239       "member": "Ext.data.reader.Reader",
240       "type": "Mixed",
241       "doc": "<p>The raw data object that was last passed to readRecords. Stored for further processing if needed</p>\n",
242       "private": false,
243       "static": false,
244       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Reader.js",
245       "linenr": 266,
246       "html_filename": "Reader.html",
247       "href": "Reader.html#Ext-data-reader-Reader-property-rawData"
248     },
249     {
250       "tagname": "property",
251       "name": "xmlData",
252       "member": "Ext.data.reader.Xml",
253       "type": "Object",
254       "doc": "<p>DEPRECATED - will be removed in <a href=\"#/api/Ext\" rel=\"Ext\" class=\"docClass\">Ext</a> JS 5.0. This is just a copy of this.rawData - use that instead</p>\n",
255       "private": false,
256       "static": false,
257       "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Xml.js",
258       "linenr": 299,
259       "html_filename": "Xml.html",
260       "href": "Xml.html#Ext-data-reader-Xml-property-xmlData"
261     }
262   ],
263   "event": [
264
265   ],
266   "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/reader/Xml.js",
267   "linenr": 1,
268   "html_filename": "Xml.html",
269   "href": "Xml.html#Ext-data-reader-Xml",
270   "cssVar": [
271
272   ],
273   "cssMixin": [
274
275   ],
276   "component": false,
277   "superclasses": [
278     "Ext.data.reader.Reader"
279   ],
280   "subclasses": [
281
282   ],
283   "mixedInto": [
284
285   ],
286   "allMixins": [
287
288   ]
289 });