Do you have to use a remote source for Spry datasets?

A user on cf-talk today posted about a problem he was having with Spry. He had tested with an XML file, but then he switched to passing an XML string directly to Spry:

<script> var dsTasks = new Spry.Data.XMLDataSet("<cfoutput>#tasks#</cfoutput>","tasks/task"); </script>

This isn’t valid. However, there is a way to do this in Spry. Simply create your dataset with a null url:

var dsTasks = new Spry.Data.XMLDataSet(null, "tasks/task");

Then create an XML object out of your string:

var xmlDOMDocument = Spry.Utils.stringToXMLDoc(xmlStr);

Finally, tell the dataset to use your XML object as the data:

dsTasks.setDataFromDoc(xmlDOMDocument);

A live example of this may be found here:

http://labs.adobe.com/technologies/spry/samples/data_region/XMLStringSample.html

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate looking for his next gig. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments