sher17
sher17

Reputation: 617

Is there a starts-with /contains function in xpath to search for a node name

Sample XML that I use can be shown as below;

<Response>
      <custom_field>
         <duedate_176307 null="true"/>
         <smsalertsent_176307 null="true"/>
         <surveygizmoid_176307 null="true"/>
      </custom_field>
<Response>

I want to retrieve the value in which the name of the node starts with 'smsalertsent'. Is there a way to construct the xpath expression to get it done like a 'starts-with' or 'contains' kind of aproach?

Upvotes: 1

Views: 238

Answers (1)

Flynn1179
Flynn1179

Reputation: 12075

Use this:

/Response/custom_field/*[starts-with(local-name(),'smsalertsent')]

Upvotes: 2

Related Questions