是否可以使用xpath获得第二个最后一个元素,即"778-893-3551“,而不对表达式末尾的任何数字进行硬编码?我试过:
//section[@id="postingbody"]/text()我不想用这样的东西
//section[@id="postingbody"]/text()[2]因为,如果任何项丢失或项与其编号不同,则表达式末尾使用的序列号不会带来任何结果。
下列值的元素:
<section id="postingbody">Located in the heart of Guildford. Surrey, Built in 2014, looks and feels new. No GST. Still under 2/5/10 National New Home Warranty. Timeless Craftsman-style architecture, with wood and hardy plank exterior. Open floor plan with 9' ceiling on the main floor. 30" ceran top electric range self-cleaning oven and stainless steel 3 door fridge. Contemporary Real Maple cabinets. 2 Storey clubhouse with Gym, Sauna, Party hall & Guest Suite. Easy access to No. walking distance to Guildford mall, library and all the services you desire, very convenient location, 8 minutes drive to a skytrain station, 2 minutes drive to hwy 1.<br>
2 covered parking.<br>
10 minutes drive from Coquitlam Centre.<br>
<br>
Call to make an appointment to view the place.<br>
<br>
Ahmed Afandi<br>
778-893-3551<br>
Kore Realty Central</section>发布于 2017-05-05 10:16:06
可以将选定元素的位置设置为last-1
//section[@id="postingbody"]/text()[position()=last()-1]https://stackoverflow.com/questions/43802102
复制相似问题