我有一个具有以下结构的xml文件:
<field>
<title>Wrong</title>
<value>Don't want this</value>
</field>
<field>
<title>Dialogue Text</title>
<value>The gold is here</value>
</field>
我如何使用jQuery来获取value-tag内的文本,但前提是其上方的title-tag内的文本是“ Dialogue Text”?
换句话说,如何根据标题标签的内容选择值?
如果您正在寻找有效的集合,则可以执行以下操作:
var validValues=$(xml).find('title').filter( function(){
return $(this).text() === 'Dialogue Text';
}).siblings('value');
/* now do something with the collection of value tags */
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句