Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
选择XML集合中的特定项_Xml_Xslt_Xpath - Fatal编程技术网

选择XML集合中的特定项

选择XML集合中的特定项,xml,xslt,xpath,Xml,Xslt,Xpath,考虑以下XML <account> <discussionPoints> <education category="a" value="1"/> <education category="b" value="42"/> <education category="c" value="55"/> </discussionPoints> </account>

考虑以下XML

<account>
    <discussionPoints>
        <education category="a" value="1"/>
        <education category="b" value="42"/>
        <education category="c" value="55"/>
    </discussionPoints>
</account>

我试图得到教育的价值,其中类别是“a”。特定的教育可能存在,也可能不存在。discussionPoints集合将始终存在,尽管它可能为空。我是XSLT新手,需要一些指导



编辑修复了不正确的结束标记

使用以下XPath表达式:

/account/discussionPoints/education[@category='a']/@value


它跟随子轴三次以匹配
教育
元素。然后,它检查属性轴是否为
类别
,而不遵循它(如谓词中所述),然后,假设
类别
的值为
'a'
,它再次沿着属性轴获取
value
属性的值。

使用以下XPath表达式:
/account/discussionPoints/education[@category='a']/@value
,就是这样!如果你不介意的话,请回答这个问题,这样我就可以选择正确的答案。