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 = "" 
    
    # Read the input XML Fragment
    while line = gets()
    	xmlText += line
    end
    
    doc = Document.new xmlText
    
    
    #XPath selector for picking up the name of the movie for which the description contains the substring "bit"
    puts doc.elements["collection/movie[contains(\description, 'bit')]/@title"]
    
  • + 0 comments

    puts doc.elements["collection/movie[contains(\description, 'bit')]/@title"]

  • + 2 comments

    puts doc.elements["collection/movie[@title='Trigun']/@title"] this is for the example. This is for the code submission: puts doc.elements["collection/movie[contains(/description,'bit')]/@title"]

  • + 0 comments

    Here is Querying XML Datastores with XPath -6 problem solution - https://www.gyangav.com/2022/11/hackerrank-querying-xml-datastores-with-xpath-6-problem-solution.html

  • + 0 comments
    puts doc.elements["collection/movie[contains(/description, 'bit')]/@title"]