1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-data.writer.Xml'>/**
2 </span> * @author Ed Spencer
3 * @class Ext.data.writer.Xml
4 * @extends Ext.data.writer.Writer
6 * <p>Writer that outputs model data in XML format</p>
8 Ext.define('Ext.data.writer.Xml', {
10 /* Begin Definitions */
12 extend: 'Ext.data.writer.Writer',
13 alternateClassName: 'Ext.data.XmlWriter',
19 <span id='Ext-data.writer.Xml-cfg-documentRoot'> /**
20 </span> * @cfg {String} documentRoot The name of the root element of the document. Defaults to <tt>'xmlData'</tt>.
21 * If there is more than 1 record and the root is not specified, the default document root will still be used
22 * to ensure a valid XML document is created.
24 documentRoot: 'xmlData',
26 <span id='Ext-data.writer.Xml-cfg-defaultDocumentRoot'> /**
27 </span> * @cfg {String} defaultDocumentRoot The root to be used if {@link #documentRoot} is empty and a root is required
28 * to form a valid XML document.
30 defaultDocumentRoot: 'xmlData',
32 <span id='Ext-data.writer.Xml-cfg-header'> /**
33 </span> * @cfg {String} header A header to use in the XML document (such as setting the encoding or version).
34 * Defaults to <tt>''</tt>.
38 <span id='Ext-data.writer.Xml-cfg-record'> /**
39 </span> * @cfg {String} record The name of the node to use for each record. Defaults to <tt>'record'</tt>.
44 writeRecords: function(request, data) {
49 root = me.documentRoot,
51 needsRoot = data.length !== 1,
56 xml.push(me.header || '');
58 if (!root && needsRoot) {
59 root = me.defaultDocumentRoot;
63 xml.push('<', root, '>');
66 for (; i < len; ++i) {
68 xml.push('<', record, '>');
70 if (item.hasOwnProperty(key)) {
71 xml.push('<', key, '>', item[key], '</', key, '>');
74 xml.push('</', record, '>');
78 xml.push('</', root, '>');
81 request.xmlData = xml.join('');
85 </pre></pre></body></html>