我想從一個網頁內容選擇一些細節如何在Xpath中選擇文本?
<div id="realty_widget_property_description" class="property_block realty_widget_property_description widget widget-2 alt">
<p class="title "><strong>Apartment for Rent </strong></p>
<div class="property-description ">
<p class="property_description">
</p><p>– Property ID: P-000324<br>
– Location: Phsar Chas<br>
– Price: $350/month<br>
– Bed/Bath: 2 beds/2 Baths<br>
– Size: 4m x 18m<br>
– Story: 1st<br>
– Fully Furnished<br>
– Description: This apartment is in residential area and good location for living with comfortable and fresh air. There are 2 bedrooms, 2 bathrooms, a living room, a kitchen and the balcony. Close to everywhere in town such as school, market, clinic, Bank, coffee shop and just ride a few minutes to Phsar Chas Market.<br>
我如何選擇物業編號,地點,價格,尺寸,故事和說明,如果他們都留在同一個班?
您使用的是哪個版本的XPath,您想要哪種數據?在您顯示的最後一個'p'元素中有文本節點,您可以用例如'// div [@id ='realty_widget_property_description']/div [@class ='property-description']/p [2]/text()',這會給你例如' - 房產編號:P-000324',' - 位置:Phsar Chas'等。 –
我想一個一個選擇它而不是全選 – july77
然後添加一個位置謂詞,例如'/ div [@id ='realty_widget_property_description']/div [@class ='property-description']/p [2]/text()[1]'給你一個字符串值爲' - Property ID :P-000324'。 –