lis = doc.xpath('//li') # Or however you are getting the right elements
data = Hash[ lis.map{ |li| [li.at('h6').text, li.search('p').last.text] }]
#=> {
#=> "Russia" => "1,287,498",
#=> "USA" => "782,2378,223",
#=> }
p data["Russia"]
#=> "1,287,498"
This answer assumes that the <p>
with the number is the last paragraph in the <li>
. It's hard to know if this is correct as you have not shared a full document.