Print Friendly

# Class Ext.data.XmlReader

Package: | Ext.data
Class: | XmlReader
Extends: | Ext.data.DataReader
Defined In: | XmlReader.js

Data reader class to create an Array of Ext.data.Record objects from an XML document based on mappings in a provided Ext.data.Record constructor.

The code below lists all configuration options.

    var myReader = new Ext.data.XmlReader({
       record: "row",           // The repeated element which contains record information
       totalRecords: "results", // The element which contains the number of returned records (optional)
       id: "id"                 // The element within the record that provides an ID for the record (optional)
    }, myRecordDefinition);

This would consume an XML file like this:

    <?xml?>
    <dataset>
     <results>2</results>
     <row>
       <id>1</id>
       <name>Bill</name>
     </row>
     <row>
       <id>2</id>
       <name>Ben</name>
     </row>
    </dataset>

Properties - Methods - Events - Config Options

## Public Properties

Property | Defined By
--- | ---
| xmlData : XMLDocument | XmlReader
After any data loads/reads, the raw XML Document is available for further custom processing.

## Public Methods

Method | Defined By
--- | ---
| XmlReader(`Object meta`, `Mixed recordType`) | XmlReader
Create a new XmlReader
| read(`Object response`) : Object | XmlReader
This method is only used by a DataProxy which has retrieved data from a remote server.
| readRecords(`Object doc`) : Object | XmlReader
Create a data block containing Ext.data.Records from an XML document.

## Public Events

This class has no public events.

## Config Options

Config Options | Defined By
--- | ---
| id : String | XmlReader
The DomQuery path relative from the record element to the element that contains a record identifier value.
| record : String | XmlReader
The DomQuery path to the repeated element which contains record information.
| success : String | XmlReader
The DomQuery path to the success attribute used by forms.
| totalRecords : String | XmlReader
The DomQuery path from which to retrieve the total number of records in the dataset. This is only needed if the whole...

## Property Details

### xmlData

`public XMLDocument xmlData`
After any data loads/reads, the raw XML Document is available for further custom processing.
This property is defined by XmlReader.

## Constructor Details

### XmlReader

`public function XmlReader(`Object meta`, `Mixed recordType`)`
Create a new XmlReader
Parameters:

- `meta` : Object
  Metadata configuration options
- `recordType` : Mixed
  The definition of the data record type to produce. This can be either a valid Record subclass created with Ext.data.Record.create, or an array of objects with which to call Ext.data.Record.create. See the Ext.data.Record class for more details.

## Method Details

### read

`public function read(`Object response`)`
This method is only used by a DataProxy which has retrieved data from a remote server.
Parameters:

- `response` : Object
  The XHR object which contains the parsed XML document. The response is expected to contain a method called 'responseXML' that returns an XML document object.

Returns:

- `Object`
  records A data block which is used by an {@link Ext.data.Store} as a cache of Ext.data.Records.

This method is defined by XmlReader.

### readRecords

`public function readRecords(`Object doc`)`
Create a data block containing Ext.data.Records from an XML document.
Parameters:

- `doc` : Object
  A parsed XML document.

Returns:

- `Object`
  records A data block which is used by an {@link Ext.data.Store} as a cache of Ext.data.Records.

This method is defined by XmlReader.

## Config Details

### id

`id : String`
The DomQuery path relative from the record element to the element that contains a record identifier value.
This config option is defined by XmlReader.

### record

`record : String`
The DomQuery path to the repeated element which contains record information.
This config option is defined by XmlReader.

### success

`success : String`
The DomQuery path to the success attribute used by forms.
This config option is defined by XmlReader.

### totalRecords

`totalRecords : String`
The DomQuery path from which to retrieve the total number of records in the dataset. This is only needed if the whole dataset is not passed in one go, but is being paged from the remote server.
This config option is defined by XmlReader.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.