我有一個對象,它是<td>
標記的子對象。類是ctext
和相關數據是<b>
tag.tag將Nokogiri XML對象轉換爲字符串而不使用.text
我已經選擇使用節點內:
td.css(".ctext b")
,它似乎工作。我得到的是這樣一個結果:
<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>
如果我使用:
td.css(".ctext b").text
將其轉換爲字符串,我得到:
FlyingAt the beginning of each combat, choose first strike, vigilance, or lifelink. Creatures you control gain that ability until end of turn.
我需要的是能夠將(我認爲這是一個Nokogiri xml節點)轉換爲字符串而不剝離HTML標記。我需要保持<br>
。
謝謝! 我知道這是一個單獨的問題,但我遇到了頁面上另一個元素的文本問題。有問題的頁面是:http://magiccards.info/gtc/en/1.html。當我嘗試並解析頁面的斜體部分時,我會看到一個奇怪的重疊:
-Predak,無門自由圖像攻擊,沒有恐懼或猶豫,在那個瞬間你可以獲得偉大。 – 2013-04-09 09:56:46