How to return single string value of XPath expression?

后端 未结 1 1448
醉酒成梦
醉酒成梦 2021-01-21 08:19

This is my HTML:



Description

相关标签:
1条回答
  • 2021-01-21 08:30

    string(/) will return the string value of the whole document.


    Update: To return the four separate strings returned by this XPath,

    .//h3[@class='description-area']/following-sibling::p//text()[count(preceding-sibling::br) >= 0]
    

    as a single string, wrap the above XPath similarly in string():

    string(.//h3[@class='description-area']/following-sibling::p//text()[count(preceding-sibling::br) >= 0])
    

    Update 2: But the br and text() maneuvers aren't necessary. You can simply get the string value of the p:

    string(.//h3[@class='description-area']/following-sibling::p)
    
    0 讨论(0)
提交回复
热议问题