KPrince36
KPrince36

Reputation: 2936

Wildcards in XPath Predicate

I am trying to write an xpath expression that would evaluate to a specific substring within 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>

I know I likely need contain() and to use predicates. The string within will be extremely long and there will a specific substring that I am looking for. I'm not sure how to use a wildcard within the text. Here is my idea of what it may look like.

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

Upvotes: 1

Views: 1315

Answers (1)

choroba
choroba

Reputation: 241858

There are no wildcards. Just specify the literal substring:

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

Upvotes: 5

Related Questions