DOM Level 3 XPath in Internet Explorer

Yes, there’s still no XPath support in IE =/. For me, the most reliable way to use document.evaluate in every browser is, sadly, via a library. It’s called Wicked Good XPath and it’s a recent Google-authored rewrite of the old good JavaScript-XPath library. I’ve been using Wicked Good XPath since the release and have been … Read more

How to get H1,H2,H3,… using a single xpath expression

Use: /html/body/*[self::h1 or self::h2 or self::h3]/text() The following expression is incorrect: //html/body/*[local-name() = “h1” or local-name() = “h2” or local-name() = “h3”]/text() because it may select text nodes that are children of unwanted:h1, different:h2, someWeirdNamespace:h3. Another recommendation: Always avoid using // when the structure of the XML document is statically known. Using // most often … Read more

How do I use a default namespace in an lxml xpath query?

Something like this should work: import lxml.etree as et ns = {“atom”: “http://www.w3.org/2005/Atom”} tree = et.fromstring(xml) for node in tree.xpath(‘//atom:entry’, namespaces=ns): print node See also http://lxml.de/xpathxslt.html#namespaces-and-prefixes. Alternative: for node in tree.xpath(“//*[local-name() = ‘entry’]”): print node

Retrieve an xpath text contains using text()

text() gets you a set of text nodes. I tend to use it more in a context of //span//text() or something. If you are trying to check if the text inside an element contains something you should use contains on the element rather than the result of text() like this: span[contains(., ‘testuser’)] XPath is pretty … Read more

Does jsoup support xpath?

JSoup doesn’t support XPath yet, but you may try XSoup – “Jsoup with XPath”. Here’s an example quoted from the projects Github site (link): @Test public void testSelect() { String html = “<html><div><a href=”https://github.com”>github.com</a></div>” + “<table><tr><td>a</td><td>b</td></tr></table></html>”; Document document = Jsoup.parse(html); String result = Xsoup.compile(“//a/@href”).evaluate(document).get(); Assert.assertEquals(“https://github.com”, result); List<String> list = Xsoup.compile(“//tr/td/text()”).evaluate(document).list(); Assert.assertEquals(“a”, list.get(0)); Assert.assertEquals(“b”, list.get(1)); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)