You are viewing a single comment's thread. Return to all comments →
require 'rexml/document' include REXML
xmlText = ""
while line = gets() xmlText += line end
doc = Document.new xmlText
description = doc.elements["/collection/movie[2]/description"].text puts description.length
Seems like cookies are disabled on this browser, please enable them to open this website
Querying XML Datastores with XPath - 8
You are viewing a single comment's thread. Return to all 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
Write the XPath selector for finding the number of characters (i.e, the string-length) in the description of the second movie in the XML file.
Fill in the blanks to complete the required XPath selector query
description = doc.elements["/collection/movie[2]/description"].text puts description.length