python - XPath invalid expression when tag name has curly braces -
the name of tag trying {http://whitehatsec.com/xml-api-vuln}description. conveniently every tag prefixed lovely reference whitehat website. unfortunately xpath in lxml doesn't it. trying vuln_root[0].xpath('//\{http://whitehatsec.com/xml-api-vuln\}description') should me right node. lxml keeps saying
file "test.py", line 23, in <module> s in vuln_root[0].xpath('//\{http://whitehatsec.com/xml-api-vuln\}description'): file "lxml.etree.pyx", line 1509, in lxml.etree._element.xpath (src/lxml/lxml.etree.c:50725) file "xpath.pxi", line 318, in lxml.etree.xpathelementevaluator.__call__ (src/lxml/lxml.etree.c:146020) file "xpath.pxi", line 238, in lxml.etree._xpathevaluatorbase._handle_result (src/lxml/lxml.etree.c:145028) file "xpath.pxi", line 224, in lxml.etree._xpathevaluatorbase._raise_eval_error (src/lxml/lxml.etree.c:144883) lxml.etree.xpathevalerror: invalid expression
how can around awful tag naming in xpath? thanks
the easiest approach here map namespace.
el.xpath('//vuln:description', namespaces={'vuln': 'http://whitehatsec.com/xml-api-vuln'})
Comments
Post a Comment