PDA

View Full Version : CDATA content not displaying in Grid and XMLDataModel



xsolonix
13 Jan 2007, 1:50 PM
I'm trying to put an xml document that contains cdata sections using a grid and xmldatamodel.
The 'ilegal' text is not displayed in the grid even though it is in a cdata section.
Any ideas? Help please!


<?xml version="1.0" encoding="UTF-8" ?>
<DocumentElement>
<Mail>
<id><![CDATA[1]]></id>
<from><![CDATA[aa<a@gmail.com>]]></from>
<to><![CDATA[<a@gmail.com>]]></to>
<body><![CDATA[

---------- Forwarded message ----------
<span class="gmail_quote">From: <b class="gmail_sendername">a[/b] &lt;a@gmail.com&gt;
Date: Jan 12, 2007 4:27 PM

Subject: test3
To: a@gmail.com

</span>test3

]]></body>
<datesent><![CDATA[2007-01-12T22:21:45-05:00]]></datesent>
<subject><![CDATA[Fwd: test3]]></subject>
</Mail>
</DocumentElement>


var XmlExample = {

init : function(){

dataModel = new YAHOO.ext.grid.XMLDataModel({
tagName: 'Mail',
id: 'id',
fields: ['from', 'to', 'body', 'datesent','subject']
});
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "from", width: 120, sortable: true},
{header: "to", width: 180, sortable: true},
{header: "body", width: 100, sortable: true},
{header: "datesent", width: 100, sortable: true},
{header: "subject", width: 180, sortable: true}
]);

// create the Grid
var grid = new YAHOO.ext.grid.Grid('example-grid', dataModel, colModel);
grid.autoWidth = true;
grid.autoHeight = true;
grid.render();


dataModel.load('xml.xml');
}
}
YAHOO.ext.EventManager.onDocumentReady(XmlExample.init, XmlExample, true);

tryanDLS
13 Jan 2007, 2:38 PM
Did you try setting a BP in Firebug to look at the xml as it's processed in the datamodel.load method?

I'm not sure what you expect to get loaded - if everything is a comment, I'm not sure what's going to be pulled out of the xmldocument to load.