dojo.provide("dojox.data.dom"); //DOM type to int value for reference. //Ints make for more compact code than full constant names. //ELEMENT_NODE = 1; //ATTRIBUTE_NODE = 2; //TEXT_NODE = 3; //CDATA_SECTION_NODE = 4; //ENTITY_REFERENCE_NODE = 5; //ENTITY_NODE = 6; //PROCESSING_INSTRUCTION_NODE = 7; //COMMENT_NODE = 8; //DOCUMENT_NODE = 9; //DOCUMENT_TYPE_NODE = 10; //DOCUMENT_FRAGMENT_NODE = 11; //NOTATION_NODE = 12; //FIXME: Remove this file when possible. //This file contains internal/helper APIs as holders until the true DOM apis of Dojo 0.9 are finalized. //Therefore, these should not be generally used, they are present only for the use by XmlStore and the //wires project until proper dojo replacements are available. When such exist, XmlStore and the like //will be ported off these and this file will be deleted. dojo.experimental("dojox.data.dom"); dojox.data.dom.createDocument = function(/*string?*/ str, /*string?*/ mimetype){ // summary: // cross-browser implementation of creating an XML document object. // // str: // Optional text to create the document from. If not provided, an empty XML document will be created. // If str is empty string "", then a new empty document will be created. // mimetype: // Optional mimetype of the text. Typically, this is text/xml. Will be defaulted to text/xml if not provided. var _document = dojo.doc; if(!mimetype){ mimetype = "text/xml"; } if(str && dojo.trim(str) !== "" && (typeof dojo.global["DOMParser"]) !== "undefined"){ var parser = new DOMParser(); return parser.parseFromString(str, mimetype); // DOMDocument }else if((typeof dojo.global["ActiveXObject"]) !== "undefined"){ var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ]; for(var i = 0; i1){ var _document = node.ownerDocument || dojo.doc; //Preference is to get the node owning doc first or it may fail dojox.data.dom.replaceChildren(node, _document.createTextNode(text)); return text; // string } else { if(node.textContent !== undefined){ //FF 1.5 return node.textContent; // string } var _result = ""; if(node == null){ return _result; //empty string. } for(var i = 0; i < node.childNodes.length; i++){ switch(node.childNodes[i].nodeType){ case 1: // ELEMENT_NODE case 5: // ENTITY_REFERENCE_NODE _result += dojox.data.dom.textContent(node.childNodes[i]); break; case 3: // TEXT_NODE case 2: // ATTRIBUTE_NODE case 4: // CDATA_SECTION_NODE _result += node.childNodes[i].nodeValue; break; default: break; } } return _result; // string } } dojox.data.dom.replaceChildren = function(/*Element*/node, /*Node || array*/ newChildren){ // summary: // Removes all children of node and appends newChild. All the existing // children will be destroyed. // description: // Removes all children of node and appends newChild. All the existing // children will be destroyed. // node: // The node to modify the children on // newChildren: // The children to add to the node. It can either be a single Node or an // array of Nodes. var nodes = []; if(dojo.isIE){ for(var i=0;i