XPath谓词中的通配符

时间:2013-04-29 23:43:51

标签: xpath

我正在尝试编写一个xpath表达式,该表达式将计算为ItemInfo

中的特定子字符串
<Catalog>
   <List>
      <Item>
        <ItemInfo>
            This describes the Item In which it is listed.
        </ItemInfo>
      </Item>
      <Item>
        <ItemInfo>
            This is another item description.
        </ItemInfo>
      </Item>
   </List>
</Catalog>

我知道我可能需要contains()并使用谓词。其中的字符串将非常长,并且我将寻找一个特定的子字符串。我不确定如何在文本中使用通配符。这是我对它的外观的看法。

> /Catalog/List//Item/ItemInfo[contains(.,*'another'*)]

1 个答案:

答案 0 :(得分:3)

没有通配符。只需指定文字子字符串:

/Catalog/List//Item/ItemInfo[contains(.,'another')]
相关问题