OpmlStore is a simple read-only store provided by Dojo and contained in the DojoX project. OpmlStore is a read interface to work with Opml formatted XML files. Similar to ItemFileReadStore, OpmlStore reads the contents from an http endpoint or a browser DOM object that contains Opml formatted data.
The following dojo.data APIs are implemented by OpmlStore
The following example shows an Opml data source:
geography.opml 2006-11-10 2006-11-13 Magellan, Ferdinand
Note: An item in OpmlStore is an entry. The atributes defined in the tag make up the attributes that are exposed for that item. Any child items (nested tags) are accessable using the special attribute children.
The constructor for OpmlStore takes the following possible parameters in its keyword args:
ags for it to be effective.The fetch method query syntax for OpmlStore is simple and straightforward. It allows a list of attributes to match against in an AND fashion, just like ItemFileReadStore. For example, the following query object locates all items that have attributes of those names that match both of those values:
{ foo:"bar", bit:"bite"}
Note that OpmlStore supports the use of wild cards (multi-character * and single character ?) in its attribute value matching.
To find all items with attribute foobar, the query would be:
{ foo:"bar*"}
To find all items with attribute foo that value ends with ar, and ignoring only the first character, the query would be:
{ foo:"?ar"}
NOTE: Other stores should follow the same semantics in defining queries for consistency.
For these examples, we'll assume a datasource as defined by the example data format in this page.
Avar store = new dojox.data.OpmlStore({url: "grography.xml", label: "Text"});
var gotContinents = function(items, request){
for (var i = 0; i < items.length; i++){
var item = items[i];
console.log("Located continent: " + store.getLabel(item);
}
}
var request = store.fetch({query: {text: "A*", type: "continent"}, onComplete: gotContinents});
A, case insensitivelyvar store = new dojox.data.OpmlStore({url: "grography.xml", label: "Text"});
var gotContinents = function(items, request){
for (var i = 0; i < items.length; i++){
var item = items[i];
console.log("Located continent: " + store.getLabel(item);
}
}
var request = store.fetch({query: {text: "a*", type: "continent"}, queryOptions: {ignoreCase: true}, onComplete: gotContinents});
For further examples refer to the test cases provided in dojox.data.tests.