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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xpath based on part of node-name ?

Status
Not open for further replies.

sheila11

Programmer
Dec 27, 2000
251
US
Hi All,

I have a large number of nodes in my xml documents that have names ending with "-para". For example, <labor-para>, <supervisor-para>, <manager-para> etc.

Is there a way to fetch them by using xpath ? Something like:
<xsl:template match="*'para'" >

Is this possible ?

TIA,
Sheila
 
Try
<xsl:template match="[substring-after('//', '-')='para']"/>

Good Luck
 
Thanks a lot, Wiszh. One more question:

If 'para' can occur anywhere in the name, (just in case,) wdn't this do the same ?

<xsl:template match="*[contains(name(.), 'para')]">

TIA,
Sheila
 
It might, but I have never used the contains function so I can't say for sure. The contains function as-per the definition should do that, but you may have to work out the exact syntax.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top