How to select XML tag based on value of its child tag in Inno Setup

ε祈祈猫儿з 提交于 2019-12-04 20:07:08

Remember, that I've suggested you this question as a closer match to your needs:
XPath to select element based on childs child value.

So, your XPath should be:

XMLNodeList :=
  XMLDocument.SelectNodes('//listaMonedas/item[moneda/text()="LIBRA ESTERLINA"]');

Meaning, that you want to select the item tag, that contains moneda child tag with LIBRA ESTERLINA text.


Also as you expect a single match only (don't you?), you should use SelectSingleNode and your code will be much simpler:

XMLNode :=
  XMLDocument.SelectSingleNode('//listaMonedas/item[moneda/text()="LIBRA ESTERLINA"]');

id       :=  XMLNode.SelectSingleNode('id').Text;
moneda   :=  XMLNode.SelectSingleNode('moneda').Text;
dollar   :=  XMLNode.SelectSingleNode('dollar').Text;
abr      :=  XMLNode.SelectSingleNode('abr').Text;
singPlur :=  XMLNode.SelectSingleNode('singPlur').Text;
caracter :=  XMLNode.SelectSingleNode('caracter').Text;

MsgBox(id+moneda+dollar+abr+singPlur+caracter, mbInformation, MB_OK); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!