【问题标题】:Select element where attribute contains a certain substring选择属性包含某个子字符串的元素
【发布时间】:2019-07-30 08:06:17
【问题描述】:

查看来自xml 文件的以下摘录,如果有多个活动实例,我将如何使用xpath 返回name (Test Name) 的值,其中活动的id 属性包含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>

【问题讨论】:

    标签: c# xml xpath


    【解决方案1】:
    //activity[contains(@id,'5WnweCI2lzT')]/name/text()
    

    请注意,如果多个节点包含标识符,这将返回多个结果。

    【讨论】:

      猜你喜欢
      • 2012-04-27
      • 2015-12-22
      • 2014-08-31
      • 2010-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多