Why doesn’t xpath work when processing an XHTML document with lxml (in python)?

The problem is the namespaces. When parsed as XML, the img tag is in the http://www.w3.org/1999/xhtml namespace since that is the default namespace for the element. You are asking for the img tag in no namespace. Try this: >>> tree.getroot().xpath( … “//xhtml:img”, … namespaces={‘xhtml’:’http://www.w3.org/1999/xhtml’} … ) [<Element {http://www.w3.org/1999/xhtml}img at 11a29e0>]

Table vertical header?

Just use <th> as the first element in the row. Then add the scope attribute, which has no visual impact, but you could use it e.g. in CSS. <table> <tbody> <tr> <th scope=”row”>A</th> <td>b</td> </tr> <tr> <th scope=”row”>C</th> <td>d</td> </tr> </tbody> </table> See also http://www.w3.org/TR/WCAG20-TECHS/H63

how to set background image in submit button?

The way I usually do it, is with the following css: div#submitForm input { background: url(“../images/buttonbg.png”) no-repeat scroll 0 0 transparent; color: #000000; cursor: pointer; font-weight: bold; height: 20px; padding-bottom: 2px; width: 75px; } and the markup: <div id=”submitForm”> <input type=”submit” value=”Submit” name=”submit”> </div> If things look different in the various browsers I implore you … Read more

Enable & Disable a Div and its elements in Javascript [duplicate]

You should be able to set these via the attr() or prop() functions in jQuery as shown below: jQuery (< 1.7): // This will disable just the div $(“#dcacl”).attr(‘disabled’,’disabled’); or // This will disable everything contained in the div $(“#dcacl”).children().attr(“disabled”,”disabled”); jQuery (>= 1.7): // This will disable just the div $(“#dcacl”).prop(‘disabled’,true); or // This will … Read more

JSF/Facelets: why is it not a good idea to mix JSF/Facelets with HTML tags?

During the JSF 1.0/1.1 ages this was indeed “not a good idea”, because all the HTML was not automatically taken in the JSF component tree when using JSP as view technology. All plain HTML was eagerly by JSP rendered before the JSF component tree. E.g. <p>Lorem ipsum <h:outputText value=”#{bean.value1}”> dolor sit amet<p> <p>Consectetur adipiscing <h:inputText … Read more

How do I fix wrongly nested / unclosed HTML tags?

using BeautifulSoup: from BeautifulSoup import BeautifulSoup html = “<p><ul><li>Foo” soup = BeautifulSoup(html) print soup.prettify() gets you <p> <ul> <li> Foo </li> </ul> </p> As far as I know, you can’t control putting the <li></li> tags on separate lines from Foo. using Tidy: import tidy html = “<p><ul><li>Foo” print tidy.parseString(html, show_body_only=True) gets you <ul> <li>Foo</li> </ul> … Read more