kashasa
kashasa

Reputation:

template match using xpath query

my xml has some node with same attribute and i would like to pull them using some xpath hope you can help so it basically looks like this

<myxml>
 <something Type="AT_SAS_6"/>
 <something Type="AT_SAS_50"/>
 <something Type="AT_SAS_200"/>
</myxml>

i know that if it was on the name i could do something like

<xsl:template match=*[starts-with(name(),  'AT_SAS')]">

is there anyway to do the same to attribute value?

Upvotes: 1

Views: 157

Answers (2)

JP Alioto
JP Alioto

Reputation: 45127

I think the XPATH you're looking for is ...

myxml/something[starts-with(@Type, "AT_")]

Upvotes: 2

cakeforcerberus
cakeforcerberus

Reputation: 4657

Preface attribute names with @ and you can use them in your xpath expressions. Just write a template to match to your root node (myxml), loop through all child "something"'s and then pull the attribute with something like this:

<xsl:value-of select="./@Type" />

Upvotes: 0

Related Questions