Thanks chone, I'll see if I can use it.
On 16 feb, 22:26, chone <[email protected]> wrote: > this is the solution i used in my application > use this Request.XML create the instance for request xml file > > Request.XML = new Class({ > Extends: Request, > success: function(text, xml){ > if(Browser.Features.xpath) { > xml.selectNodes = function(xpath){ > var nodes = []; > var result = this.evaluate(xpath, this, > this.createNSResolver(xml.documentElement), > XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; > if (result){ > var node = result.iterateNext() ; > while(node){ > nodes.push(node); > node = result.iterateNext();} > } > return nodes; > } > > xml.selectSingleNode = function(xpath){ > var result = this.evaluate(xpath, this, > this.createNSResolver(this.documentElement), 9, null); > if (result && result.singleNodeValue) return result.singleNodeValue ; > else return [] ;} > // ie > }else { > > xml = this.createXML(xml.documentElement);} > > this.onSuccess(text, xml);}, > > createXML : function(xml, parent) { > if(!$defined(parent)) { > parent = new Element(xml.nodeName);} > > if (xml.childNodes.length) { > for (var i = 0; i < xml.childNodes.length; i++) { > if (xml.childNodes[i].nodeType == 1) { // Element type > // NodeName > var el = new Element(xml.childNodes[i].nodeName); > // Attributes > if (xml.childNodes[i].attributes.length) { > for (var j = 0; j < xml.childNodes[i].attributes.length; j++) { > var property = xml.childNodes[i].attributes[j].nodeName; > var value = xml.childNodes[i].attributes[j].nodeValue; > el.setProperty(property, value);} > } > > // Value > if (xml.childNodes[i].firstChild) { > var text = xml.childNodes[i].firstChild.nodeValue; > if ($defined(text)){ > el.set('text', text);} > } > > parent.adopt(el); > var son = xml.childNodes[i]; > if (son.childNodes.length) { > this.createXML(son, el); > > } > } > } > } > return parent; > } > });
