ext怎样从XML获取内容,并原样显示出来

所问问题如题

用Ext.data.XmlReader
[code="js"]

Class Ext.data.XmlReader
Package: Ext.data
Defined In: XmlReader.js
Class: XmlReader
Extends: DataReader
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" or "application/xml".

Example code:

var Employee = 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 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)
}, Employee);
This would consume an XML file like this:

<?xml version="1.0" encoding="UTF-8"?>

2

1
Bill
Gardener


2
Ben
Horticulturalist

[/code]