开发者

What is wrong with this XPath?

开发者 https://www.devze.com 2023-04-09 07:27 出处:网络
Give开发者_JAVA技巧n that the path /XML/Staff/Content/ContentXML/StaffProfile/Role is correct, and that I have 5 /XML/Staff with only one Staff member with the Role of \"Partner\"

Give开发者_JAVA技巧n that the path /XML/Staff/Content/ContentXML/StaffProfile/Role is correct, and that I have 5 /XML/Staff with only one Staff member with the Role of "Partner"

Why does this match all 5 staff members?

<xsl:apply-templates select="/XML/Staff[Content/ContentXML/StaffProfile/Role='Partner']" mode="List"/>


I haven't seen your XML (which you should post for completeness), but I assume Role is an XML element and if that's the case, comparing it to a string won't work. Try this:

<xsl:apply-templates 
    select="/XML/Staff[Content/ContentXML/StaffProfile/Role/text()='Partner']"
    mode="List" />

If Role is an attribute, you need to do this:

<xsl:apply-templates 
    select="/XML/Staff[Content/ContentXML/StaffProfile/@Role='Partner']"
    mode="List" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号