How to make string matching case insensitiv [text()="sTrInG"] in python (lxml)? -


i have xpath pattern:

tags = doc.xpath('/html/body//a[text() = "' + name.encode('utf8') + '"]/@href' 

this returns url of every -tag name name text in it. possible case insensitiv matching of name?

edit

when trying @shelhamer solution get:

>>> a_tag_list = html_string.xpath('/html/body//a[lower-case(text()) = "' + author_name.lower() + '"]/@href')   file "lxml.etree.pyx", line 1459, in lxml.etree._element.xpath (src/lxml/lxml.etree.c:40530)   file "xpath.pxi", line 324, in lxml.etree.xpathelementevaluator.__call__ (src/lxml/lxml.etree.c:113864)   file "xpath.pxi", line 242, in lxml.etree._xpathevaluatorbase._handle_result (src/lxml/lxml.etree.c:113063)   file "xpath.pxi", line 227, in lxml.etree._xpathevaluatorbase._raise_eval_error (src/lxml/lxml.etree.c:112894) lxml.etree.xpathevalerror: unregistered function 

this can done using lower-case function: tags = doc.xpath('/html/body//a[lower-case(text()) = "' + name.encode('utf8') + '"]/@href'

a helpful list of functions here: http://www.w3schools.com/xpath/xpath_functions.asp


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -