0
我正在嘗試使用xpath從下面的XML查詢Exchange ID。以下工作。XPATH查詢值
/companies[@type="array"]/company[1]/subject_datas[@type="array"]/subject_data[5]/value/text()
但我只是注意到,如果所有的自定義字段不會在高層填寫,然後他們並不在同一個順序,以便
/companies[@type="array"]/company[1]/subject_datas[@type="array"]/subject_data[5]/value/text()
並不總是拉交易所寄過去ID
是否有另一種方法可以編寫此xpath以始終獲得Exchange ID的值?
<?xml version="1.0" encoding="UTF-8"?>
<companies type="array">
<company>
<author-id type="integer">1151899</author-id>
<background></background>
<created-at type="datetime">2015-08-11T13:49:21Z</created-at>
<group-id type="integer" nil="true"></group-id>
<id type="integer">239684969</id>
<owner-id type="integer" nil="true"></owner-id>
<updated-at type="datetime">2017-05-03T17:46:46Z</updated-at>
<visible-to>Everyone</visible-to>
<name>Test Company</name>
<avatar_url></avatar_url>
<contact-data>
<twitter-accounts type="array"/>
<email-addresses type="array">
<email-address>
<address>[email protected]</address>
<id type="integer">126789186</id>
<location>Work</location>
</email-address>
</email-addresses>
<phone-numbers type="array">
<phone-number>
<id type="integer">192421740</id>
<location>Work</location>
<number>444 333 6490</number>
</phone-number>
</phone-numbers>
<web-addresses type="array">
<web-address>
<id type="integer">192421741</id>
<location>Work</location>
<url>http://www.123process.com/</url>
</web-address>
</web-addresses>
<addresses type="array">
<address>
<city>New York</city>
<country>United States</country>
<id type="integer">114818436</id>
<location>Work</location>
<state>NY</state>
<street>444 Winter Way</street>
<zip>10007</zip>
</address>
</addresses>
<instant-messengers type="array"/>
</contact-data>
<subject_datas type="array">
<subject_data>
<id type="integer">162387754</id>
<subject_field_id type="integer">1009158</subject_field_id>
<subject_field_label>Agency Extension</subject_field_label>
<value>ABCDF</value>
</subject_data>
<subject_data>
<id type="integer">162387755</id>
<subject_field_id type="integer">1009161</subject_field_id>
<subject_field_label>Agency ID</subject_field_label>
<value>68</value>
</subject_data>
<subject_data>
<id type="integer">162387756</id>
<subject_field_id type="integer">1009162</subject_field_id>
<subject_field_label>Edition</subject_field_label>
<value>Pro</value>
</subject_data>
<subject_data>
<id type="integer">162387757</id>
<subject_field_id type="integer">1009157</subject_field_id>
<subject_field_label>License Count</subject_field_label>
<value>1</value>
</subject_data>
<subject_data>
<id type="integer">215707824</id>
<subject_field_id type="integer">1161358</subject_field_id>
<subject_field_label>Exchange ID</subject_field_label>
<value>FBB52CA3-DC19-4992-AB2C-7235FABD9129</value>
</subject_data>
</subject_datas>
</company>
</companies>
你說的意思是:'如果所有的自定義字段中不Highrise'填寫 – SomeDude