DarkW1nter
DarkW1nter

Reputation: 2861

Select element where attribute contains a certain substring

Looking at the following extract from an xml file, if there are multiple instances of activity how would I use xpath to return the value of name (Test Name) where id attribute of activity contains 5WnweCI2lzT?

<activity type="http://adlnet.gov/expapi/activities/module" id="http://5gISGNPekh5_course_id/5WnweCI2lzT">
    <name lang="und">Test</name>
    <description lang="und">Test</description>
</activity>

Upvotes: 0

Views: 55

Answers (1)

Barry O&#39;Kane
Barry O&#39;Kane

Reputation: 1187

//activity[contains(@id,'5WnweCI2lzT')]/name/text()

Note that this will return multiple results where more than one node contains the identifier.

Upvotes: 3

Related Questions