1 <div xmlns:ext="http://www.extjs.com" class="body-wrap"><div class="inheritance res-block"><pre class="res-block-inner"><a href="output/Ext.data.DataReader.html" ext:member="" ext:cls="Ext.data.DataReader">DataReader</a> <img src="resources/elbow-end.gif">XmlReader</pre></div><h1>Class <a href="source/XmlReader.html#cls-Ext.data.XmlReader">Ext.data.XmlReader</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.data</td></tr><tr><td class="label">Defined In:</td><td class="hd-info">XmlReader.js</td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/XmlReader.html#cls-Ext.data.XmlReader">XmlReader</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info"><a href="output/Ext.data.DataReader.html" ext:cls="Ext.data.DataReader" ext:member="">DataReader</a></td></tr></table><div class="description"><p>Data reader class to create an Array of <a href="output/Ext.data.Record.html" ext:cls="Ext.data.Record">Ext.data.Record</a> objects from an XML document
2 based on mappings in a provided <a href="output/Ext.data.Record.html" ext:cls="Ext.data.Record">Ext.data.Record</a> constructor.</p>
3 <p><b>Note</b>: that in order for the browser to parse a returned XML document, the Content-Type
4 header in the HTTP response must be set to "text/xml" or "application/xml".</p>
6 <pre><code><b>var</b> Employee = Ext.data.Record.create([
7 {name: <em>'name'</em>, mapping: <em>'name'</em>}, <i>// <em>"mapping"</em> property not needed <b>if</b> it is the same as <em>"name"</em></i>
8 {name: <em>'occupation'</em>} <i>// This field will use <em>"occupation"</em> as the mapping.</i>
10 <b>var</b> myReader = <b>new</b> Ext.data.XmlReader({
11 totalProperty: <em>"results"</em>, <i>// The element which contains the total dataset size (optional)</i>
12 record: <em>"row"</em>, <i>// The repeated element which contains row information</i>
13 idProperty: <em>"id"</em> <i>// The element within the row that provides an ID <b>for</b> the record (optional)</i>
14 messageProperty: <em>"msg"</em> <i>// The element within the response that provides a user-feedback message (optional)</i>
15 }, Employee);</code></pre>
17 This would consume an XML file like this:
18 <pre><code><?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?>
20 <results>2</results>
23 <name>Bill</name>
24 <occupation>Gardener</occupation>
28 <name>Ben</name>
29 <occupation>Horticulturalist</occupation>
31 </dataset></code></pre></div><div class="hr"></div><a id="Ext.data.XmlReader-configs"></a><h2>Config Options</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Config Options</th><th class="msource-header">Defined By</th></tr><tr class="config-row expandable inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-fields"></a><b><a href="source/DataReader.html#cfg-Ext.data.DataReader-fields">fields</a></b> : Array/Object<div class="mdesc"><div class="short">Either an Array of Field definition objects (which
32 will be passed to Ext.data.Record.create, or a Record
33 constructo...</div><div class="long"><p>Either an Array of <a href="output/Ext.data.Field.html" ext:cls="Ext.data.Field">Field</a> definition objects (which
\r
34 will be passed to <a href="output/Ext.data.Record.html#Ext.data.Record-create" ext:member="create" ext:cls="Ext.data.Record">Ext.data.Record.create</a>, or a <a href="output/Ext.data.Record.html" ext:cls="Ext.data.Record">Record</a>
\r
35 constructor created from <a href="output/Ext.data.Record.html#Ext.data.Record-create" ext:member="create" ext:cls="Ext.data.Record">Ext.data.Record.create</a>.</p></div></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#fields" ext:member="#fields" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="config-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-idPath"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-idPath">idPath</a></b> : String<div class="mdesc">The DomQuery path relative from the record element to the element that contains
36 a record identifier value.</div></td><td class="msource">XmlReader</td></tr><tr class="config-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-messageProperty"></a><b><a href="source/DataReader.html#cfg-Ext.data.DataReader-messageProperty">messageProperty</a></b> : String<div class="mdesc">[undefined] Optional name of a property within a server-response that represents a user-feedback message.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#messageProperty" ext:member="#messageProperty" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="config-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-record"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-record">record</a></b> : String<div class="mdesc">The DomQuery path to the repeated element which contains record information.</div></td><td class="msource">XmlReader</td></tr><tr class="config-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-record"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-record">record</a></b> : String<div class="mdesc">The DomQuery path to the repeated element which contains record information.</div></td><td class="msource">XmlReader</td></tr><tr class="config-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-successProperty"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-successProperty">successProperty</a></b> : String<div class="mdesc">The DomQuery path to the success attribute used by forms.</div></td><td class="msource">XmlReader</td></tr><tr class="config-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-totalProperty"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-totalProperty">totalProperty</a></b> : String<div class="mdesc"><div class="short">The DomQuery path from which to retrieve the total number of records
37 in the dataset. This is only needed if the whole...</div><div class="long">The DomQuery path from which to retrieve the total number of records
38 in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
39 paged from the remote server.</div></div></td><td class="msource">XmlReader</td></tr></tbody></table><a id="Ext.data.XmlReader-props"></a><h2>Public Properties</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Property</th><th class="msource-header">Defined By</th></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-buildExtractors"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-buildExtractors">buildExtractors</a></b> : Object<div class="mdesc">Abstract method, overridden in DataReader extensions such as <a href="output/Ext.data.JsonReader.html" ext:cls="Ext.data.JsonReader">Ext.data.JsonReader</a> and <a href="output/Ext.data.XmlReader.html" ext:cls="Ext.data.XmlReader">Ext.data.XmlReader</a></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#buildExtractors" ext:member="#buildExtractors" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-extractData"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-extractData">extractData</a></b> : Object<div class="mdesc">Abstract method overridden in DataReader extensions such as <a href="output/Ext.data.JsonReader.html" ext:cls="Ext.data.JsonReader">Ext.data.JsonReader</a> and <a href="output/Ext.data.XmlReader.html" ext:cls="Ext.data.XmlReader">Ext.data.XmlReader</a></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#extractData" ext:member="#extractData" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-extractValues"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-extractValues">extractValues</a></b> : Object<div class="mdesc">Abstract method overridden in DataReader extensions such as <a href="output/Ext.data.JsonReader.html" ext:cls="Ext.data.JsonReader">Ext.data.JsonReader</a> and <a href="output/Ext.data.XmlReader.html" ext:cls="Ext.data.XmlReader">Ext.data.XmlReader</a></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#extractValues" ext:member="#extractValues" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-getId"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-getId">getId</a></b> : Object<div class="mdesc">Abstract method created in extension's buildExtractors impl.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#getId" ext:member="#getId" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-getMessage"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-getMessage">getMessage</a></b> : Object<div class="mdesc">Abstract method created in extension's buildExtractors impl.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#getMessage" ext:member="#getMessage" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-getRoot"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-getRoot">getRoot</a></b> : Object<div class="mdesc">Abstract method created in extension's buildExtractors impl.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#getRoot" ext:member="#getRoot" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-getSuccess"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-getSuccess">getSuccess</a></b> : Object<div class="mdesc">Abstract method created in extension's buildExtractors impl.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#getSuccess" ext:member="#getSuccess" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-getTotal"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-getTotal">getTotal</a></b> : Object<div class="mdesc">Abstract method created in extension's buildExtractors impl.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#getTotal" ext:member="#getTotal" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-meta"></a><b><a href="source/DataReader.html#prop-Ext.data.DataReader-meta">meta</a></b> : Mixed<div class="mdesc">This DataReader's configured metadata as passed to the constructor.</div></td><td class="msource"><a href="output/Ext.data.DataReader.html#meta" ext:member="#meta" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="property-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-xmlData"></a><b><a href="source/XmlReader.html#prop-Ext.data.XmlReader-xmlData">xmlData</a></b> : XMLDocument<div class="mdesc">After any data loads/reads, the raw XML Document is available for further custom processing.</div></td><td class="msource">XmlReader</td></tr></tbody></table><a id="Ext.data.XmlReader-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-XmlReader"></a><b><a href="source/XmlReader.html#cls-Ext.data.XmlReader">XmlReader</a></b>( <code>Object meta</code>, <code>Object recordType</code> )
40 <div class="mdesc"><div class="short">Create a new XmlReader.</div><div class="long">Create a new XmlReader.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>meta</code> : Object<div class="sub-desc">Metadata configuration options</div></li><li><code>recordType</code> : Object<div class="sub-desc">Either an Array of field definition objects as passed to
41 <a href="output/Ext.data.Record.html#Ext.data.Record-create" ext:member="create" ext:cls="Ext.data.Record">Ext.data.Record.create</a>, or a Record constructor object created using <a href="output/Ext.data.Record.html#Ext.data.Record-create" ext:member="create" ext:cls="Ext.data.Record">Ext.data.Record.create</a>.</div></li></ul><strong>Returns:</strong><ul><li>void</li></ul></div></div></div></td><td class="msource">XmlReader</td></tr><tr class="method-row expandable inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-isData"></a><b><a href="source/DataReader.html#method-Ext.data.DataReader-isData">isData</a></b>( <code>Object data</code> )
43 Boolean<div class="mdesc"><div class="short">Returns true if the supplied data-hash looks and quacks like data. Checks to see if it has a key
44 corresponding to i...</div><div class="long">Returns true if the supplied data-hash <b>looks</b> and quacks like data. Checks to see if it has a key
\r
45 corresponding to idProperty defined in your DataReader config containing non-empty pk.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>data</code> : Object<div class="sub-desc"></div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#isData" ext:member="#isData" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-read"></a><b><a href="source/XmlReader.html#method-Ext.data.XmlReader-read">read</a></b>( <code>Object response</code> )
47 Object<div class="mdesc"><div class="short">This method is only used by a DataProxy which has retrieved data from a remote server.</div><div class="long">This method is only used by a DataProxy which has retrieved data from a remote server.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>response</code> : Object<div class="sub-desc">The XHR object which contains the parsed XML document. The response is expected
48 to contain a property called <tt>responseXML</tt> which refers to an XML document object.</div></li></ul><strong>Returns:</strong><ul><li><code>Object</code><div class="sub-desc">records A data block which is used by an {@link Ext.data.Store} as
49 a cache of Ext.data.Records.</div></li></ul></div></div></div></td><td class="msource">XmlReader</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-readRecords"></a><b><a href="source/XmlReader.html#method-Ext.data.XmlReader-readRecords">readRecords</a></b>( <code>Object doc</code> )
51 Object<div class="mdesc"><div class="short">Create a data block containing Ext.data.Records from an XML document.</div><div class="long">Create a data block containing Ext.data.Records from an XML document.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>doc</code> : Object<div class="sub-desc">A parsed XML document.</div></li></ul><strong>Returns:</strong><ul><li><code>Object</code><div class="sub-desc">records A data block which is used by an {@link Ext.data.Store} as
52 a cache of Ext.data.Records.</div></li></ul></div></div></div></td><td class="msource">XmlReader</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.XmlReader-readResponse"></a><b><a href="source/XmlReader.html#method-Ext.data.XmlReader-readResponse">readResponse</a></b>( <code>String action</code>, <code>Object response</code> )
54 Ext.data.Response<div class="mdesc"><div class="short">Decode a json response from server.</div><div class="long">Decode a json response from server.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>action</code> : String<div class="sub-desc">[<a href="output/Ext.data.Api.html#Ext.data.Api-actions" ext:member="actions" ext:cls="Ext.data.Api">Ext.data.Api.actions</a> create|read|update|destroy]</div></li><li><code>response</code> : Object<div class="sub-desc">HTTP Response object from browser.</div></li></ul><strong>Returns:</strong><ul><li><code>Ext.data.Response</code><div class="sub-desc">response Returns an instance of {@link Ext.data.Response}</div></li></ul></div></div></div></td><td class="msource">XmlReader</td></tr><tr class="method-row expandable inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-realize"></a><b><a href="source/DataReader.html#method-Ext.data.DataReader-realize">realize</a></b>( <code>Record/Record[] record</code>, <code>Object/Object[] data</code> )
56 void<div class="mdesc"><div class="short">Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from ser...</div><div class="long">Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from server.
\r
57 You <b>must</b> return at least the database pk using the idProperty defined in your DataReader configuration. The incoming
\r
58 data from server will be merged with the data in the local record.
\r
59 In addition, you <b>must</b> return record-data from the server in the same order received.
\r
60 Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be suppressed.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>record</code> : Record/Record[]<div class="sub-desc">The phantom record to be realized.</div></li><li><code>data</code> : Object/Object[]<div class="sub-desc">The new record data to apply. Must include the primary-key from database defined in idProperty field.</div></li></ul><strong>Returns:</strong><ul><li>void</li></ul></div></div></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#realize" ext:member="#realize" ext:cls="Ext.data.DataReader">DataReader</a></td></tr><tr class="method-row expandable inherited"><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.data.DataReader-update"></a><b><a href="source/DataReader.html#method-Ext.data.DataReader-update">update</a></b>( <code>Record/Record[] rs</code>, <code>Object/Object[] data</code> )
62 void<div class="mdesc"><div class="short">Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.
63 If returning ...</div><div class="long">Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.
\r
64 If returning data from multiple-records after a batch-update, you <b>must</b> return record-data from the server in
\r
65 the same order received. Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be
\r
66 suppressed as the record receives fresh new data-hash<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>rs</code> : Record/Record[]<div class="sub-desc"></div></li><li><code>data</code> : Object/Object[]<div class="sub-desc"></div></li></ul><strong>Returns:</strong><ul><li>void</li></ul></div></div></div></td><td class="msource"><a href="output/Ext.data.DataReader.html#update" ext:member="#update" ext:cls="Ext.data.DataReader">DataReader</a></td></tr></tbody></table><a id="Ext.data.XmlReader-events"></a><h2>Public Events</h2><div class="no-members">This class has no public events.</div></div>