Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to open http://www.x.org/releases/current/doc/man/man3/xcb_grab_keyboard.3.xhtml in Firefox, but it fails with a XML parsing error. Chromium has a similar issue with it, but it shows at least the document until the error.

Both results are unwanted, I just want to get the page parsed as HTML. What options do I have other than using a different browser?

share|improve this question
    
save link as... then change extention to html (or investigate why it is faulty and report to webmaster) (IE7 forces download so I tihnk it's the content-type that's not getting set) –  ratchet freak Sep 25 '12 at 9:02
add comment

2 Answers

up vote 4 down vote accepted

For static documents, the following bookmarklet will work as intended: The XHTML document will be displayed as (not-so-strict) HTML.

javascript:(function(){
 var x = new XMLHttpRequest();
 x.open('GET', location.href);
 x.onload = function() {
   var d = document.implementation.createHTMLDocument('');
   d.documentElement.innerHTML = x.responseText.replace(/^[\S\s]*?<html\b/i, '<html');
   document.replaceChild(d.documentElement, document.documentElement);
 };
 x.send();
})();

I'm stripping the first characters up to the <html> tag. Otherwise, everything ends up in the <body> tag. Consequently, styles (and scripts) would not be applied quite well.

share|improve this answer
    
Neat, I tried something similiar using document.write (ugly) or innerHTML/replaceChild or DOMParser, but none of them worked. This works great, thanks! –  Lekensteyn Sep 25 '12 at 9:10
add comment

If it's only once in a while, you can devote a bit of manual effort. When you see the XML parsing error, you can go back, right-click on the link, and choose "Save link as". Then edit your copy of the HTML to correct the error. Open your corrected copy in your browser.

By deleting the "</table>" tag that was noted in the parsing error, I was able to view the page that you indicated.

share|improve this answer
    
This will break hyperlinks and is also inconvenient given that there are multiple pages on that site that are broken. Isn't there a special URL of setting to get XHTML parsed as HTML? Also, I am not actually interested in fixing the markup and want to have the flexibility of browsers being able to parse malformed HTML without complaint. Having some display errors is fine, as long as I can read the page. –  Lekensteyn Sep 25 '12 at 9:05
    
OK, thanks for your clarification. –  minopret Sep 25 '12 at 9:10
    
+1 because it is a usable solution. –  Lekensteyn Sep 25 '12 at 9:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.