4

How would I get the following (using the % for a LIKE statement) --

assets['HasEN'] = self.node.xpath('//data_file[@role="source"]/locale[@name="en%"]')

In other words, the name could be en, it could be en-US, it could be en-GB, etc.

Is there a way to do that with lxml or do I have to do that after parsing the XML?

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    Maybe this will help you: http://stackoverflow.com/questions/12495723/using-xpath-wildcards-in-attributes-in-selenium-webdriver – David K. Hess Mar 16 '15 at 00:10

1 Answers1

8

You can use this syntax:

/locale[starts-with(@name, "en")]
David542
  • 104,438
  • 178
  • 489
  • 842