Would it be better to write it into an iframe so you can have a proper DOM model and extract it from there?
_____ From: Matthew Hazlett [mailto:[email protected]] Sent: Sunday, 2 May 2010 4:35 PM To: [email protected] Subject: RE: [Moo] ajax and the dom http://mootools.net/shell/s5GE4/ Writes your request to a hidden div then parses it with moo selectors. Note: it only writes the span tag out from the returned elements (ignores the paragraph tag). From: [email protected] [mailto:[email protected]] On Behalf Of chone Sent: Sunday, May 02, 2010 2:03 AM To: [email protected] Subject: Re: [Moo] ajax and the dom that have a demo? 2010/5/2 brook <[email protected]> hi all. i am using ajax request and i am having to use a supid hackish way to parse the dom so i thought i would ask if there was a better way to do it... below i explain what i have done - but what i want to do is 1) make an ajax request that loads a different webpage and put that into a variable called "page" 2) parse the "page" to get particular elements of the dom like this page.getElement('myelement') this is the dumb solution i came up with .... i have a function that starts like, function(e,elm,index,grp){ this.request = e.href this.fireEvent("pageRequest") var req = new Request({ url: e.href, onSuccess: function(htmlstring) { var newpage = new Element('div',{id: 'ajaxholder'}) this.page = newpage.set('html',htmlstring) ...... the important part is that that an ajax request is made and on success i pass the html-string that is returned into a div and pass that to a variable named "page". then to parse then i parse the dom by doing something annoying like... menu.page.getChildren('div.center')[0].getChildren('div#box') [0].getChildren('div#top')[0] where "menu" is the instance of the class containing the above function and the "page" variable. the page being loaded has all the headers and such of a new page (this is important because i want it to degrade nicely if javascript is turned off). so esential i have a div that looks like <div id="ajaxholder"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html.... obviously this is dumb. i really want to be able to parse html in the normal way... ie menu.page.getElement('top') i am assuming this is some standard thing i am just missing. thanks for the help. brook
