We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
xml_data = <
War, Thriller
DVD
2001
PG
10
Talk about a war
Science Fiction
DVD
1980
R
7
Science Fiction
Action
DVD
4
PG
10
Quite a bit of action!
Comedy
VHS
PG
2
Boring
EOF
Case 0 is ok but case 1 is wrong, any idea ?? about how can i solve it :I
doc = Document.new(xml_data)
doc.elements.each("collection/movie/popularity") do |ele|
puts ele.text
end
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Querying XML Datastores with XPath - 2
You are viewing a single comment's thread. Return to all comments →
require 'rexml/document' include REXML
xml_data = < War, Thriller DVD 2001 PG 10 Talk about a war Science Fiction DVD 1980 R 7 Science Fiction Action DVD 4 PG 10 Quite a bit of action! Comedy VHS PG 2 Boring EOF
Case 0 is ok but case 1 is wrong, any idea ?? about how can i solve it :I doc = Document.new(xml_data) doc.elements.each("collection/movie/popularity") do |ele| puts ele.text end