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.
Querying XML Datastores with XPath - 2
Querying XML Datastores with XPath - 2
Sort by
recency
|
7 Discussions
|
Please Login in order to post a comment
require 'rexml/document' include REXML
xmlText = "movies.xml"
while line = gets() xmlText += line end
doc = Document.new xmlText
puts doc.elements.each("collection/movie//popularity/text()")
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
Here is Querying XML Datastores with XPath - 2 problem solution - https://www.gyangav.com/2022/11/hackerrank-querying-xml-datastores-with-xpath-2-problem-solution.html
require 'rexml/document' include REXMLto STDOUT xmlText = "" while line = gets() xmlText += line end doc = Document.new xmlText puts doc.elements.each("collection/movie/popularity/text()")
selector query puts doc.elements.each("collection/movie/popularity/text()")