Properties Methods Events Config Options Direct Link
DataReader
  XmlReader

Class CQ.Ext.data.XmlReader

Package:CQ.Ext.data
Class:XmlReader
Extends:CQ.Ext.data.DataReader
Clientlib:cq.widgets

Data reader class to create an Array of CQ.Ext.data.Record objects from an XML document based on mappings in a provided CQ.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" or "application/xml".

Example code:

var Employee = CQ.Ext.data.Record.create([
   {name: 'name', mapping: 'name'},     // "mapping" property not needed if it is the same as "name"
   {name: 'occupation'}                 // This field will use "occupation" as the mapping.
]);
var myReader = new CQ.Ext.data.XmlReader({
   totalProperty: "results", // The element which contains the total dataset size (optional)
   record: "row",           // The repeated element which contains row information
   idProperty: "id"         // The element within the row that provides an ID for the record (optional)
   messageProperty: "msg"   // The element within the response that provides a user-feedback message (optional)
}, Employee);

This would consume an XML file like this:

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
 <results>2</results>
 <row>
   <id>1</id>
   <name>Bill</name>
   <occupation>Gardener</occupation>
 </row>
 <row>
   <id>2</id>
   <name>Ben</name>
   <occupation>Horticulturalist</occupation>
 </row>
</dataset>

Config Options

Config Options Defined By
  idPath : String
The DomQuery path relative from the record element to the element that contains a record identifier value.
XmlReader
  messageProperty : String
[undefined] Optional name of a property within a server-response that represents a user-feedback message.
DataReader
  record : String
The DomQuery path to the repeated element which contains record information.
XmlReader
  successProperty : String
The DomQuery path to the success attribute used by forms.
XmlReader

Public Properties

Property Defined By
  buildExtractors : Object
Abstract method, overridden in DataReader extensions such as CQ.Ext.data.JsonReader and CQ.Ext.data.XmlReader
DataReader
  extractValues : Object
Abstract method overridden in DataReader extensions such as CQ.Ext.data.JsonReader and CQ.Ext.data.XmlReader
DataReader
  getId : Object
Abstract method created in extension's buildExtractors impl.
DataReader
  getMessage : Object
Abstract method created in extension's buildExtractors impl.
DataReader
  getRoot : Object
Abstract method created in extension's buildExtractors impl.
DataReader
  getSuccess : Object
Abstract method created in extension's buildExtractors impl.
DataReader
  getTotal : Object
Abstract method created in extension's buildExtractors impl.
DataReader
  meta : Mixed
This DataReader's configured metadata as passed to the constructor.
DataReader
  xmlData : XMLDocument
After any data loads/reads, the raw XML Document is available for further custom processing.
XmlReader

Public Methods

Method Defined By

Public Events

This class has no public events.