我有一个< td >标签的子对象.类是ctext,相关数据在< b >tag.tag内
我使用以下方法选择了节点:
td.css(".ctext b")
Run Code Online (Sandbox Code Playgroud)
它似乎工作.我得到的结果如下:
< b >Flying< br >< br >At the beginning of each combat, choose first strike, vigilance, or lifelink. Creatures you control gain that ability until end of turn.< /b >
Run Code Online (Sandbox Code Playgroud)
如果我使用:
td.css(".ctext b").text
Run Code Online (Sandbox Code Playgroud)
把它转换成字符串,我得到:
FlyingAt the beginning of each combat, choose first strike, vigilance, or lifelink. Creatures you control gain that ability until end of turn.
Run Code Online (Sandbox Code Playgroud)
我需要的是能够将td.css(".ctext b")我认为是Nokogiri xml节点的字符串转换为字符串而不剥离HTML标记.我需要保留< br >s.