Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPath attribute wildcard

Status
Not open for further replies.

MattOwens

Programmer
Oct 27, 2004
5
IN
Hi,

Does anyone know if its possible to perform a wild carded attribute search in XPath? For example,

"\\element[@attribute='wildc*']"

I can't seem to get it working - the example is obvious why as its embedded in a character array. Perhaps an XPath function?

Thanks in Advance
Matt
 
Matt,

(Welcome back to Tek-Tips!)

Regular experessions are not supported by XPath. However, I think that your needs can be met fairly easily.

I take it from your example that you want to select the elements (named element in the default namespace), for which a certain attribute (named attribute) has a value that begins with the characters 'wildc'.

An XPath expression to select this nodeset might be:
Code:
//element[substring(@attribute,1,5)='wildc']

Is this what you had in mind?

Tom Morrison
 
Hi Tom,
Yes, thats exactly what i was looking for, in that substr effectively can be used as a wild card. thanks a lot
cheers
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top