我有以下 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 表达式,如果 具有这些值之一的 elemtn,则该表达式将匹配。我最好的尝试:product/discount
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有什么问题?
德玛西亚99
RISEBY
相关分类