Skip to content Skip to sidebar Skip to footer

Xpath-expression Works With Literal But Not With Variable

I have an XML file containing data looking as follows: cashflow_id whereas you want to have the value, convert it to a f-string and pass in the variable cashflow_id like this and it works:

value_I_want = tree.xpath(f"//CASHFLOW_FIELD[@CASHFLOW_ID={cashflow_id} and @FIELDNAME='C254']/@VALUE")

Post a Comment for "Xpath-expression Works With Literal But Not With Variable"