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?