У меня есть следующая полезная нагрузка XML:
<?xml version="1.0" encoding="UTF-8" ?>
<product>
<discount class="standard">
<id>123</id>
<beginDate>20181205</beginDate>
<endDate>20181225</endDate>
</discount>
<account>12345</account>
</product>
Атрибут class
в элементе discount
может иметь следующие значения:
standard
special
custom
sale
Я пытаюсь написать выражение XPath, которое будет соответствовать, если у него есть product/discount
elemtn с class
одного из этих значений. Моя лучшая попытка:
/product/discount[@class]/[@class = 'standard' or @class = 'special' or @class = 'customer' or @class = 'sale']
выдает следующую ошибку:
InvalidXPathExpression: Invalid xpath: /product/discount[@class]/[@class = 'standard' or @class = 'special' or @class = 'customer' or @class = 'sale']. Reason: javax.xml.xpath.XPathExpressionException: javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
Есть идеи, что не так с моим XPath?