我是 touchxml 和 xpath 的新手,我只想知道是否有任何方法可以动态获取节点的属性?我有这个xml
<?xml version="1.0" encoding="UTF-8"?>
<countries>
<country id="Philippines">
<countryname>Philippines</countryname>
<subsidiaries>
<subsidiary>
<name>Sartorius Philippines Inc.</name>
<address>Unit 20-A The World Centre Building, 330 Senator Gil Puyat Avenue Makati 1209 City Philippines, Philippines</address>
<phone>+63.2.8640.929</phone>
<fax>+63.28640.932</fax>
<email>enquiry.philippines@sartorius.com</email>
<website>http://www.sartorius-mechatronics.com.ph</website>
</subsidiary>
</subsidiaries>
</country>
<country id="Denmark">
<countryname>Denmark</countryname>
<subsidiaries>
<subsidiary>
<name>Sartorius Stedim Nordic A|S</name>
<address>stedim Hoerskaetten 6d 2630 Taastrup, Denmark</address>
<phone>+45.7023.4400</phone>
<fax>+45.4630.4030</fax>
<email>ne.customersupport@sartorius.com</email>
<website></website>
</subsidiary>
<subsidiary>
<name>Sartorius Nordic A|S</name>
<address>Hoerskaetten 6D 2630 Taastrup, Denmark</address>
<phone>+45.7023.4400</phone>
<fax>+45.4630.4030</fax>
<email>ne.customersupport@sartorius.com</email>
<website></website>
</subsidiary>
</subsidiaries>
</country>
</countries>`
我有一个显示所有国家/地区名称的表格视图,我希望发生的是当我单击丹麦这个词时,它会显示 id="denmark" 的属性
我现在有这个 xpath 查询:
resultNodes = [rssParser2 nodesForXPath:@"/countries/country[@id]/subsidiaries/subsidiary" error:nil];