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.
Note that in order for the browser to parse a returned XML document, the Content-Type
header in the HTTP response must be set to "text/xml".
Example code:
var RecordDef = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.XmlReader({
totalRecords: "results", // The element which contains the total dataset size (optional)
record: "row", // The repeated element which contains row information
id: "id" // The element within the row that provides an ID for the record (optional)
}, RecordDef);
This would consume an XML file like this:
<?xml?>
<dataset>
<results>2</results>
<row>
<id>1</id>
<name>Bill</name>
<occupation>Gardener</name>
</row>
<row>
<id>2</id>
<name>Ben</name>
<occupation>Horticulturalist</occupation>
</row>
</dataset>
Properties
-
Methods
-
Events
-
Config Options
Public Properties
|
xmlData : XMLDocument |
XmlReader |
After any data loads/reads, the raw XML Document is available for further custom processing. |
Public Methods
|
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
|
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
)
Method Details
read
public function read( Object response
)
This method is only used by a DataProxy which has retrieved data from a remote server.
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
: ObjectA parsed XML document.
Returns:
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.