开发者

How do I get innerHtml using Nokogiri gem

开发者 https://www.devze.com 2023-04-11 20:51 出处:网络
e.g. i have html: <div class=\"item\"> <p> bla bla<br/> bla bla </p> </div> i need to get inner html of div.item:

e.g. i have html:

<div class="item">
    <p>
        bla bla<br/>
        bla bla
    </p>
</div>

i need to get inner html of div.item:

 <p>
    bla bla<br/>
    bla bla
 </p>

i know that i can use:

doc.css("div.item:first").text

text method return clean text without any html tags

but what should i do for getting inner html of div.item?

tried:

doc.css("div.item:first").html
开发者_如何学编程

but doesn't work, documentation did not help as well

any ideas?


If you just need the string:

doc.css("div.item:first").inner_html
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号