XmlItem.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define("dojox/data/XmlItem", ["dojo/_base/declare"],
  2. function(declare) {
  3. return declare("dojox.data.XmlItem", null, {
  4. constructor: function(element, store, query){
  5. // summary:
  6. // Initialize with an XML element
  7. // element:
  8. // An XML element
  9. // store:
  10. // The containing store, if any.
  11. // query:
  12. // The query to use to look up a specific element.
  13. // Usually an XPath or dojo.query statement.
  14. this.element = element;
  15. this.store = store;
  16. this.q = query;
  17. },
  18. // summary:
  19. // A data item of 'XmlStore'
  20. // description:
  21. // This class represents an item of 'XmlStore' holding an XML element.
  22. // 'element'
  23. // element:
  24. // An XML element
  25. toString: function(){
  26. // summary:
  27. // Return a value of the first text child of the element
  28. // returns:
  29. // a value of the first text child of the element
  30. var str = "";
  31. if(this.element){
  32. for(var i = 0; i < this.element.childNodes.length; i++){
  33. var node = this.element.childNodes[i];
  34. if(node.nodeType === 3 || node.nodeType === 4){
  35. str += node.nodeValue;
  36. }
  37. }
  38. }
  39. return str; //String
  40. }
  41. });
  42. });