我的XML文件中按以下顺序排列了两行。
<component group="digitalPass" name="count">1</component>
<component group="digitalPass" name="selected_0">I</component>
我正在写下XPath并获得&#34; 1&#34; 的价值,但我想取值&#34;我&#34; < / p>
component [@group="digitalPass"]
那么如何指定name =&#34; selected_0&#34;这样我得到了理想的结果?
答案 0 :(得分:0)
Just to clarify the possible ways, if someone looks for:
1. Using 'and' plus @name
component[@group="digitalPass" and @name="selected_0"]
2. Using two [ ]'s plus @name
component[@group="digitalPass"][@name="selected_0"]
3. Using 'and' plus text comparison
component[@group="digitalPass" and text()="I"]
4. Using two [ ]'s plus text comparison
component[@group="digitalPass"][text()="I"]