[jQuery] Re: Server side JQeury
On 1月8日, 上午12時50分, "John Resig" <[EMAIL PROTECTED]> wrote: > > I am wondering why it was difficult to parse HTML at the beginning. > > Simply: Because one doesn't exist. I've since written one and hope to > be integrating it soon. > > --John Good! Server side using jquery is really useful for extracting useful information on remote sites without using many regex...
[jQuery] Re: Server side JQeury
> I am wondering why it was difficult to parse HTML at the beginning. Simply: Because one doesn't exist. I've since written one and hope to be integrating it soon. --John
[jQuery] Re: Server side JQeury
On 1月7日, 下午6時00分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jan 7, 3:46 am, howa <[EMAIL PROTECTED]> wrote: > > > > > I have been following John's > > article:http://ejohn.org/blog/bringing-the-browser-to-the-server > > > The script only support well formed XML, as defined in the function > > (env.js) > > > window.__defineSetter__("location", function(url){ > > var xhr = new XMLHttpRequest(); > > xhr.open("GET", url); > > xhr.onreadystatechange = function(){ > > curLocation = new java.net.URL( curLocation, url ); > > window.document = xhr.responseXML; > > > var event = document.createEvent(); > > event.initEvent("load"); > > window.dispatchEvent( event ); > > }; > > xhr.send(); > > }); > > > But why we need fetch valid XML? > > You don't have to use XML for sure, you can use JSON and fetch > Javascript data structures from the server-side. I think it's often > much easer for a server-side developer.. or you can just "load" plain > html text into your DOM tree(usually into a single field). > > lihao(XC) from John's site, it said: This is one part that works pretty well right now - with the huge caveat that it only works on well-formed XML documents (oops!). I'll be integrating an HTML parser into the code base so that we can make this functionality a little more resilient. In the meantime, here's an example of the sort of scraping that you can do currently: I am wondering why it was difficult to parse HTML at the beginning. Howard
[jQuery] Re: Server side JQeury
On Jan 7, 3:46 am, howa <[EMAIL PROTECTED]> wrote: > I have been following John's > article:http://ejohn.org/blog/bringing-the-browser-to-the-server > > The script only support well formed XML, as defined in the function > (env.js) > > window.__defineSetter__("location", function(url){ > var xhr = new XMLHttpRequest(); > xhr.open("GET", url); > xhr.onreadystatechange = function(){ > curLocation = new java.net.URL( curLocation, url ); > window.document = xhr.responseXML; > > var event = document.createEvent(); > event.initEvent("load"); > window.dispatchEvent( event ); > }; > xhr.send(); > }); > > But why we need fetch valid XML? You don't have to use XML for sure, you can use JSON and fetch Javascript data structures from the server-side. I think it's often much easer for a server-side developer.. or you can just "load" plain html text into your DOM tree(usually into a single field). lihao(XC)