简体   繁体   中英

Nokogiri XML Parsing with Ruby Sinatra

I'm having difficulty selecting a URL within an XML document using Nokogiri, have tried using CSS selectors which works fine apart from markup within the child. I think this has to be due to the brackets < being written as &lt and &gt. Is there a way around this?

&lt;br /&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://url.com/"&gt;https://url.com/&lt;/a&gt;
require 'cgi'
CGI.unescapeHTML('&lt;br /&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://url.com/"&gt;https://url.com/&lt;/a&gt;')

gives

<br /><strong>URL:</strong> <a href=\"https://url.com/\">https://url.com/</a>

Maybe you just need to unescape your html first

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM