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 - 9
Querying XML Datastores with XPath - 9
Sort by
recency
|
10 Discussions
|
Please Login in order to post a comment
Delving into XML fragments and XPath selectors can be a puzzle worth solving. When it comes to creative gym interior design, a similar spirit of problem-solving and creativity comes into play. Just as you're tasked with finding the right XPath selector, designing a gym space involves crafting an environment that balances form and function. It's the art of finding the perfect fit, whether in code or design.
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
Write the XPath selector for listing the title of the second movie for which the marked shelf = "B".
Fill in the blanks to complete the required XPath selector query
puts doc.elements.each("collection/movie[@shelf = 'B'][2]/@title")
Here is Querying XML Datastores with XPath - 9 problem solution - https://www.gyangav.com/2022/11/hackerrank-querying-xml-datastores-with-xpath-9-problem-solution.html
puts doc.elements.each("collection/movie[@shelf='B'][2]/@title")
above line runs successfully
My Answer:("/collection/movie[@shelf='B'][2]/@title")