用于查找重复节点值的Xpath

时间:2018-01-05 20:15:02

标签: xml xpath

我有以下xml文件:

<Dictionary>
   <words>
       <word>AM</word>       
   </words>
   <words>
       <word>AN</word>
   </words>
   <words>
       <word>AN</word>
   </words>
</Dictionary>

我需要xpath来查找重复的单词节点,如上面的“AN”是重复的。我尝试从网络搜索跟踪,但它不起作用:

/*/*[index-of(/*/*/word(), word())[2]]

2 个答案:

答案 0 :(得分:2)

选择

之前存在相同单词的单词
import tensorflow as tf

with tf.Session() as sess:
    a = tf.constant(1, name="a")
    b = tf.constant(2, name="b")
    c = tf.add(a, b, name="c")

    # prints 3
    print(sess.run(c)) 

    # prints 4 since we have fed a new value for a, for just this run.
    print(sess.run(c, feed_dict={a:2})) 

答案 1 :(得分:2)

使用following轴:

//words/word[. = ./following::word]

https://www.w3.org/TR/1999/REC-xpath-19991116/#axes