例如:
//person[@id='abc123']/@haircolor|/@weight"
Run Code Online (Sandbox Code Playgroud)
PS.有很多"人"记录
Kob*_*obi 63
试试这个:
//person[@id='abc123']/@*[name()='weight' or name()='haircolor']
Run Code Online (Sandbox Code Playgroud)
如果您使用的是XPath 2.0处理器,您还可以使用更漂亮的选项:
//person[@id='abc123']/(@haircolor|@weight)`
Run Code Online (Sandbox Code Playgroud)
pla*_*nes 24
您是否要根据多个属性的值搜索人员节点.如果这是问题那么你可以使用和例如
//person[@id='abc123' and @haircolor='blue' and @weight='...']
Run Code Online (Sandbox Code Playgroud)
如果你想搜索一个属性,但返回其他属性的值,我会做这样的事情:
<xsl:template match="person[@id='abc123']">
<xsl:value-of select="@haircolor"/>
<xsl:value-of select="@weight"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)