biojs-rest-jsdas/src/jsdas.js
function(xml, format) {
		var out = {};
		//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).
		//So, if we are in the Document element, move to its ¿¿only?? child, the root.
		if(xml.nodeType == 9) { //detect the Document node type
		  xml = xml.firstChild;
		  while(xml.nodeType != 1 && xml.nextSibling) //Document nodes (9) can't have text (3) nodes as children. Test only for elements (1)
		    xml = xml.nextSibling;
		}
		//get properties
		if (format.properties) {
			var props = format.properties;
			for (var nprop = 0, lenprop = props.length; nprop < lenprop; ++nprop) {
				var f = props[nprop];
				var name = f.jsname || f.name;
				out[name] = this.parseProperty(xml, f);
			}
		}
		//get childs
		if (format.childs) {
			var ch = format.childs;
			if (ch === 'text') { //if thextual child
				/*
				 * Due to browser compatibility the textContent may come from this 3 different methods:
				 * xml.innerText = IE
				 * xml.textContent = Firefox
				 * xml.text = IE
				 */
				out['textContent'] = xml.innerText || xml.textContent || xml.text;

			}
			else { //childs different than text
				for (var i = 0, len = ch.length; i < len; ++i) {
					var f = ch[i];
					//var els = xml.getElementsByTagName(f.tagname);
					//Hack: since getElementsByTagName is case sensitive for XML documents and DAS XMLs can be found 
					//in different casing, use a regular expresion tofilter the elements.
					//FIX: This is an unefficient parsing method. Other ways should be explored.
					var els = [];
					var all_els = xml.getElementsByTagName('*');
					for(var iael=0, lenael=all_els.length; iael<lenael; ++iael) {
					      var curr_node = all_els[iael];
					      if(new RegExp('^'+f.tagname+'$', 'i').test(curr_node.nodeName)) {
						    els.push(curr_node);
					      }
					}
					//End of tag casing hack

					if (f.mandatory && this.checkMandatoryElements && (!els || els.length == 0)) { //if a mandatory element is not present...
						//JSDAS.Console.log("Mandatory element is not present.");
					}
					if (els.length>0) { //if there are elements of the given tagName
						var name = f.jsname || f.tagname;
						if (f.multiple) { //if its a multiple instance child, create an array and push all instances
							out[name] = [];
							for (var iel = 0, lenel = els.length; iel < lenel; ++iel) {
								out[name].push(this.parseElement(els[iel], f));
							}
						}
						else {
							out[name] = this.parseElement(els[0], f);
						}
					}
				}
			}
		}
		return out;
	}
function(xml, format) {
		var out = {};
		//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).
		//So, if we are in the Document element, move to its ¿¿only?? child, the root.
		if(xml.nodeType == 9) { //detect the Document node type
		  xml = xml.firstChild;
		  while(xml.nodeType != 1 && xml.nextSibling) //Document nodes (9) can't have text (3) nodes as children. Test only for elements (1)
		    xml = xml.nextSibling;
		}
		//get properties
		if (format.properties) {
			var props = format.properties;
			for (var nprop = 0, lenprop = props.length; nprop < lenprop; ++nprop) {
				var f = props[nprop];
				var name = f.jsname || f.name;
				out[name] = this.parseProperty(xml, f);
			}
		}
		//get childs
		if (format.childs) {
			var ch = format.childs;
			if (ch === 'text') { //if thextual child
				/*
				 * Due to browser compatibility the textContent may come from this 3 different methods:
				 * xml.innerText = IE
				 * xml.textContent = Firefox
				 * xml.text = IE
				 */
				out['textContent'] = xml.innerText || xml.textContent || xml.text;

			}
			else { //childs different than text
				for (var i = 0, len = ch.length; i < len; ++i) {
					var f = ch[i];
					//var els = xml.getElementsByTagName(f.tagname);
					//Hack: since getElementsByTagName is case sensitive for XML documents and DAS XMLs can be found 
					//in different casing, use a regular expresion tofilter the elements.
					//FIX: This is an unefficient parsing method. Other ways should be explored.
					var els = [];
					var all_els = xml.getElementsByTagName('*');
					for(var iael=0, lenael=all_els.length; iael<lenael; ++iael) {
					      var curr_node = all_els[iael];
					      if(new RegExp('^'+f.tagname+'$', 'i').test(curr_node.nodeName)) {
						    els.push(curr_node);
					      }
					}
					//End of tag casing hack

					if (f.mandatory && this.checkMandatoryElements && (!els || els.length == 0)) { //if a mandatory element is not present...
						//JSDAS.Console.log("Mandatory element is not present.");
					}
					if (els.length>0) { //if there are elements of the given tagName
						var name = f.jsname || f.tagname;
						if (f.multiple) { //if its a multiple instance child, create an array and push all instances
							out[name] = [];
							for (var iel = 0, lenel = els.length; iel < lenel; ++iel) {
								out[name].push(this.parseElement(els[iel], f));
							}
						}
						else {
							out[name] = this.parseElement(els[0], f);
						}
					}
				}
			}
		}
		return out;
	}
function ( xml , format ) { var out = { } ; //The Document object does not have all the functionality of a standard node (i.e. it can't have attributes). //So, if we are in the Document element, move to its ¿¿only?? child, the root. if ( xml . nodeType == 9 ) { //detect the Document node type xml = xml . firstChild ; while ( xml . nodeType != 1 && xml . nextSibling ) //Document nodes (9) can't have text (3) nodes as children. Test only for elements (1) xml = xml . nextSibling ; } //get properties if ( format . properties ) { var props = format . properties ; for ( var nprop = 0 , lenprop = props . length ; nprop < lenprop ; ++ nprop ) { var f = props [ nprop ] ; var name = f . jsname || f . name ; out [ name ] = this . parseProperty ( xml , f ) ; } } //get childs if ( format . childs ) { var ch = format . childs ; if ( ch === 'text' ) { //if thextual child /*
				 * Due to browser compatibility the textContent may come from this 3 different methods:
				 * xml.innerText = IE
				 * xml.textContent = Firefox
				 * xml.text = IE
				 */ out [ 'textContent' ] = xml . innerText || xml . textContent || xml . text ; } else { //childs different than text for ( var i = 0 , len = ch . length ; i < len ; ++ i ) { var f = ch [ i ] ; //var els = xml.getElementsByTagName(f.tagname); //Hack: since getElementsByTagName is case sensitive for XML documents and DAS XMLs can be found  //in different casing, use a regular expresion tofilter the elements. //FIX: This is an unefficient parsing method. Other ways should be explored. var els = [ ] ; var all_els = xml . getElementsByTagName ( '*' ) ; for ( var iael = 0 , lenael = all_els . length ; iael < lenael ; ++ iael ) { var curr_node = all_els [ iael ] ; if ( new RegExp ( '^' + f . tagname + '$' , 'i' ) . test ( curr_node . nodeName ) ) { els . push ( curr_node ) ; } } //End of tag casing hack if ( f . mandatory && this . checkMandatoryElements && ( ! els || els . length == 0 ) ) { //if a mandatory element is not present... //JSDAS.Console.log("Mandatory element is not present."); } if ( els . length > 0 ) { //if there are elements of the given tagName var name = f . jsname || f . tagname ; if ( f . multiple ) { //if its a multiple instance child, create an array and push all instances out [ name ] = [ ] ; for ( var iel = 0 , lenel = els . length ; iel < lenel ; ++ iel ) { out [ name ] . push ( this . parseElement ( els [ iel ] , f ) ) ; } } else { out [ name ] = this . parseElement ( els [ 0 ] , f ) ; } } } } } return out ; }
true to raise an error if a mandatory element is not present Private functions (actually not really private. just not API documented
true to raise an error if a mandatory element is not present Private functions ( actually not really private . just not API documented