Sort by

recency

|

7 Discussions

|

  • + 0 comments
    # Standard ruby library for XML parsing
    require 'rexml/document'
    include REXML
    
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    xmlText = "movies.xml" 
    
    # Read the input XML Fragment
    while line = gets()
    	xmlText += line
    end
    
    doc = Document.new xmlText
    
    # XPath Selector for listing the popularity of the movies, in the same order as which they occur in the given XML.
    # Fill in the blanks to complete the required XPath selector query
    puts doc.elements.each("collection/movie//popularity/text()")
    
  • + 0 comments

    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()")

  • + 0 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

  • + 0 comments

    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

  • + 1 comment

    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()")