dojox.data.AtomReadStore._parseItem
dojo.require("dojox.data.AtomReadStore");
defined in dojox/data/AtomReadStore.js
Usage
function (item) (view source)
var attribs = item._attribs; var _this = this; var text, type; function getNodeText(node){ var txt = node.textContent || node.innerHTML || node.innerXML; if(!txt && node.childNodes[0]){ var child = node.childNodes[0]; if (child && (child.nodeType == 3 || child.nodeType == 4)) { txt = node.childNodes[0].nodeValue; } } return txt; } function parseTextAndType(node) { return {text: getNodeText(node),type: node.getAttribute("type")}; } dojo.forEach(item.element.childNodes, function(node){ var tagName = node.tagName ? node.tagName.toLowerCase() : ""; switch(tagName){ case "title": attribs[tagName] = { text: getNodeText(node), type: node.getAttribute("type") }; break; case "subtitle": case "summary": case "content": attribs[tagName] = parseTextAndType(node); break; case "author": var nameNode ,uriNode; dojo.forEach(node.childNodes, function(child){ if(!child.tagName){ return; } switch(child.tagName.toLowerCase()){ case "name":nameNode = child;break; case "uri": uriNode = child; break; } }); var author = {}; if(nameNode && nameNode.length == 1){ author.name = getNodeText(nameNode[0]); } if(uriNode && uriNode.length == 1){ author.uri = getNodeText(uriNode[0]); } attribs[tagName] = author; break; case "id": attribs[tagName] = getNodeText(node); break; case "updated": attribs[tagName] = dojo.date.stamp.fromISOString(getNodeText(node) );break; case "published": attribs[tagName] = dojo.date.stamp.fromISOString(getNodeText(node));break; case "category": if(!attribs[tagName]){ attribs[tagName] = []; } attribs[tagName].push({scheme:node.getAttribute("scheme"), term: node.getAttribute("term")}); break; case "link": if(!attribs[tagName]){ attribs[tagName] = []; } var link = { rel: node.getAttribute("rel"), href: node.getAttribute("href"), type: node.getAttribute("type")}; attribs[tagName].push(link); if(link.rel == "alternate") { attribs["alternate"] = link; } break; default: break; } });
parameter | type | description |
---|---|---|
item |