在Xpath中检查节点中的多个值(和)

时间:2016-06-08 19:34:29

标签: xslt xpath

XML:

<codes>
    <code>AP</code>
    <code>BS</code>
</codes

我正在尝试检查<code>是否包含&#39; AP&#39;和&#39; BS&#39;使用以下xpath。

/codes[contains(code, 'AP') and contains(code, 'BS')]

但不起作用。有没有其他方法可以找到解决方案?

2 个答案:

答案 0 :(得分:1)

如果您确实需要library(UScensus2000tract) library(ggplot2) library(spdep) # load data data("oregon.tract") # plot Census Tract map plot(oregon.tract) # create Queens contiguity matrix spatmatrix <- poly2nb(oregon.tract) #calculate the local moran of the distribution of black population lmoran <- localmoran(oregon.tract@data$black, nb2listw(spatmatrix)) # get our id from the rownames in a data.frame oregon.tract@data$id <- rownames(oregon.tract@data) oregon.tract@data$lmoran_ii <- lmoran[,1] oregon_df <- merge( # convert to a data.frame fortify(oregon.tract, region="id"), oregon.tract@data, by="id" ) ggplot(data=oregon_df, aes(x=long,y=lat,group=group)) + geom_polygon(fill=scales::col_numeric("Blues",domain=c(-1,5))(oregon_df$lmoran_ii)) + geom_path(color="white") 但不需要contains,请使用此类Xpath

exactly equal

答案 1 :(得分:0)

我怀疑你想要:

/codes[code='AP' and code='BS']
相关问题