I am trying to write an XQuery in SOAPUI to validate an XML response. What I want to do is use a "where" to see if something equals something else with a wildcard. Basically like this.
<Result>
{
for $x in //ns3:Building
where $x/ns3:BuildingNumber/text()='JJJ*' <--- This is my problem
return <Value>{$x/ns3:BuildingNumber/text()}</Value>
}
</Result>
I have taken out the namespaces for simplicity but I'm sure all of it works.
When I replace the where with something literal like the following, it works:
where $x/ns3:BuildingNumber/text()=JJJ1245
I need some kind of wildcard though but I'm not sure how or if it's done in this instance. All missions that start with JJJ. I have tried Regex and others like this but none work:
'JJJ*' '^JJJ.' 'JJJ.*'
Use matches()
for regex:
where matches($x/ns3:BuildingNumber, '^JJJ.*')
Also, be careful with text()
- usually you want string()
. This article offers a very good explanation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.