2017-06-20 222 views
0

我想知道我是否可以xpath來查詢XML Feed以僅返回那些等於特定子元素的記錄。在XML Feed上運行xpath查詢

我的XML費用返回一個屬性列表,可以是銷售,出售,讓或讓。我希望顯示那些屬性,例如To Let。

我的XML實例如下

  <properties> 
      <property> 
      <category>1</category> 
      <id>2220</id> 
      <beds>3</beds> 
      <baths>2</baths> 
      <receptions>2</receptions> 
      <price>695</price> 
      <price_alt>160</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>695.00</price_uf> 
      <base_price>695.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Terraced</property_type> 
      <property_type_id>23</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[20]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Haden Hill]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[A three bedroom terraced home which has been fully renovated to a very high standard with many sought after features. The property comprises of two reception rooms, a superb fitted kitchen with gas hob, electric oven, extractor hood to match and integrated fridge/freezer. ]]></description> 
      <postcode>WV3 9PT</postcode> 
      <available_date>2017-06-14</available_date> 
      <date_added>2017-06-14 12:23:04</date_added> 
      <date_updated>2017-06-14 13:21:06</date_updated> 
      <county>West Midlands</county> 
      <country>United Kingdom</country> 
      <transaction>2</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>To let</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>2209</id> 
      <beds>3</beds> 
      <baths>2</baths> 
      <receptions>2</receptions> 
      <price>750</price> 
      <price_alt>173</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>750.00</price_uf> 
      <base_price>750.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Semi-detached house</property_type> 
      <property_type_id>16</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[59]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Ward Road]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[A superb extended three bedroom semi detached home located on the popular Goldthorn Park Estate. The property is approached via an attractive paved front drive which provides off street parking. Two reception rooms, kitchen, utility, wet room and the three bedrooms as well as family bathroom.]]></description> 
      <postcode>WV4 5EZ</postcode> 
      <available_date>2017-11-24</available_date> 
      <date_added>2017-04-18 15:19:16</date_added> 
      <date_updated>2017-05-24 15:02:39</date_updated> 
      <county>West Midlands</county> 
      <country>United Kingdom</country> 
      <transaction>2</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>To Let</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>1103</id> 
      <beds>3</beds> 
      <baths>1</baths> 
      <receptions>2</receptions> 
      <price>750</price> 
      <price_alt>173</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>750.00</price_uf> 
      <base_price>750.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Semi-detached house</property_type> 
      <property_type_id>16</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[155]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Windsor Avenue]]></address1> 
      <address2><![CDATA[Penn]]></address2> 
      <description><![CDATA[A deceptively stunning three bedroom house which has been tastefully updated and extended to provide ample living accommodation. Comprising of front reception and extended lounge with original fireplaces, extended luxury fitted kitchen with integrated fridge, freezer, washing machine and extra wide range cooker. High specification bathroom with free standing roll top bath and separate shower cubicle. Natural rear garden and ample off street parking.]]></description> 
      <postcode>WV4 4BN</postcode> 
      <available_date>2017-08-23</available_date> 
      <date_added>2015-08-20 00:00:00</date_added> 
      <date_updated>2017-02-08 12:40:09</date_updated> 
      <county>West Midlands</county> 
      <country></country> 
      <transaction>2</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>To let</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>1179</id> 
      <beds>4</beds> 
      <baths>2</baths> 
      <receptions>2</receptions> 
      <price>850</price> 
      <price_alt>196</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>850.00</price_uf> 
      <base_price>850.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Semi-detached house</property_type> 
      <property_type_id>16</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[34]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Riches Street]]></address1> 
      <address2><![CDATA[Newbridge]]></address2> 
      <description><![CDATA[Located close to both the City Centre and West Park, this four bedroom period property offers spacious living accommodation and many original features. With lounge, large kitchen &amp; diner with fitted units. Four good sized bedrooms located over the first &amp; second floors and family bathroom. Front &amp; rear gardens and on street parking.]]></description> 
      <postcode>WV6 0DP</postcode> 
      <available_date>2016-11-30</available_date> 
      <date_added>2015-08-20 00:00:00</date_added> 
      <date_updated>2017-04-01 12:13:58</date_updated> 
      <county>West Midlands</county> 
      <country></country> 
      <transaction>2</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>To Let</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>2202</id> 
      <beds>2</beds> 
      <baths>1</baths> 
      <receptions>1</receptions> 
      <price>69,950</price> 
      <price_alt>16,142</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>69950.00</price_uf> 
      <base_price>69950.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Terraced</property_type> 
      <property_type_id>23</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[51]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Mostyn Street]]></address1> 
      <address2><![CDATA[Whitmore Reans]]></address2> 
      <description><![CDATA[Ideal First Time Purchase 
      Two Bedrooms 
      Chain Free Sale 
      Buy To Let Potential 
      Double Glazed 
      Close to City Centre &amp; University]]></description> 
      <postcode>WV1 4RR</postcode> 
      <available_date>2015-08-20</available_date> 
      <date_added>2017-03-13 17:04:57</date_added> 
      <date_updated>2017-06-01 15:25:42</date_updated> 
      <county>West Midlands</county> 
      <country></country> 
      <transaction>1</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>For sale</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>2144</id> 
      <beds>2</beds> 
      <baths>2</baths> 
      <receptions>1</receptions> 
      <price>77,950</price> 
      <price_alt>17,988</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>77950.00</price_uf> 
      <base_price>77950.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Apartment</property_type> 
      <property_type_id>8</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[134]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Essington Way]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[A very well presented ground floor apartment within a modern development, located just off the Willenhall Road, providing good access to Wolverhampton City Centre and many major routes.]]></description> 
      <postcode>WV1 2NP</postcode> 
      <available_date>2016-05-31</available_date> 
      <date_added>2016-05-31 14:48:53</date_added> 
      <date_updated>2017-05-09 10:19:04</date_updated> 
      <county>West Midlands</county> 
      <country>United Kingdom</country> 
      <transaction>1</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>For sale</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>2084</id> 
      <beds>2</beds> 
      <baths>1</baths> 
      <receptions>0</receptions> 
      <price>84,950</price> 
      <price_alt>19,604</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>84950.00</price_uf> 
      <base_price>84950.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Apartment</property_type> 
      <property_type_id>8</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[31]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Ardgowan Grove]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[Close to the Wolverhampton City Centre. The property itself is situated on the second floor and is neutrally decorated throughout, to a very high standard. The apartment features an open plan designed lounge, a modern fitted kitchen, two spacious bedrooms, and a modern bathroom with separate W.C. ]]></description> 
      <postcode>WV4 6DZ</postcode> 
      <available_date>2016-01-09</available_date> 
      <date_added>2016-01-09 16:09:56</date_added> 
      <date_updated>2016-04-21 13:16:35</date_updated> 
      <county>West Midlands</county> 
      <country>United Kingdom</country> 
      <transaction>1</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>For sale</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>1960</id> 
      <beds>3</beds> 
      <baths>1</baths> 
      <receptions>2</receptions> 
      <image> 
      </image> 
      <price>84,950</price> 
      <price_alt>19,604</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>84950.00</price_uf> 
      <base_price>84950.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Apartment</property_type> 
      <property_type_id>8</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Blakenhall</area> 
      <property_no><![CDATA[67]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Byrne Road]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[A recently refurbished terraced home close to Dudley Road shopping centre and transport links to City Centre.]]></description> 
      <postcode>WV2 3DW</postcode> 
      <available_date>2015-08-20</available_date> 
      <date_added>2015-08-20 00:00:00</date_added> 
      <date_updated>2016-01-08 10:46:37</date_updated> 
      <county>West Midlands</county> 
      <country></country> 
      <transaction>1</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>Sold</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 

      <property> 
      <category>1</category> 
      <id>2207</id> 
      <beds>3</beds> 
      <baths>1</baths> 
      <receptions>2</receptions> 
      <price>84,950</price> 
      <price_alt>19,604</price_alt> 
      <price_qualifier></price_qualifier> 
      <price_uf>84950.00</price_uf> 
      <base_price>84950.00</base_price> 
      <rate>1.0000</rate> 
      <land_size>0.00</land_size> 
      <living_space>0.00</living_space> 
      <property_type>Terraced</property_type> 
      <property_type_id>23</property_type_id> 
      <reference><![CDATA[]]></reference> 
      <area>Wolverhampton</area> 
      <property_no><![CDATA[60]]></property_no> 
      <property_name><![CDATA[]]></property_name> 
      <address1><![CDATA[Burleigh Road]]></address1> 
      <address2><![CDATA[]]></address2> 
      <description><![CDATA[A three bedroom terraced home, ideally located positioned with easy access into city centre. Good potential to be exploited as some refurbishment is required.]]></description> 
      <postcode>WV3 0HN</postcode> 
      <available_date>2017-03-27</available_date> 
      <date_added>2017-03-27 15:11:12</date_added> 
      <date_updated>2017-05-29 12:25:41</date_updated> 
      <county>West Midlands</county> 
      <country>United Kingdom</country> 
      <transaction>1</transaction> 
      <frequency>PCM</frequency> 
      <furnished>Unfurnished</furnished> 
      <status>For sale</status> 
      <currency_rate>1.000</currency_rate> 
      <custom_field1></custom_field1> 
      <custom_field2></custom_field2> 
      <custom_field3></custom_field3> 
      <custom_field4></custom_field4> 
      <custom_field5></custom_field5> 
      <custom_field6>0</custom_field6> 
      <pets>No</pets> 
      <client_key></client_key> 
      <tenure></tenure> 
      <portal_type></portal_type> 
      <portal_for></portal_for> 
      <portal_status></portal_status> 
      <latitude></latitude> 
      <longitude></longitude> 
      </property> 
      <properties> 
+0

你希望得到一張包含XPath的代碼? –

回答

0

上市使用XPath 2.0,你可以嘗試使用XPath://properties/property[status[lower-case(.)='to let']]