In Python 2.7, there is an xml library, with which I parse the file and search for tags in it. By default, this lib supports truncated XPath functionality. This raises the question: how to find the tag if I do not know the full value of its attribute, but you cannot use the built-in XPath function "contains".
There are xml:
<root> <item class="'$(param)'=='var'"> ... </item> <item class="'$(param)'=='func'"> ... </item> <item class="'$(param)'=='var_1'"> ... </item> </root> I would like to use this way to search (find all tags "item", which contain the substring "var" in the value of the attribute "class"):
xpath = "/item[contains(@class, 'var')]" But the python returns an error that the wrong predicate is being used. Tell me how to find the desired item?