Hi,
I’m new to Ruby, I’ve inherited some code for my job, and I’m trying to
understand it.
In the config.ru file, “sinatra/base” and “nokogiri” are required, and
then there is this line, which I understand:
$script = File.read(“public/script2.xml”)
@xml = Nokogiri::XML($script)
then it loads index.erb, and there is this line, which I need help with:
<% @xml.search(“property[name=steps] > array”).children.each do |step|
%>
I understand that we’re going to loop through all of the property tags
with a name attribute = “steps”.
later in that loop is this:
<%step.search(“property[name=preDialogues] > array”).children.each do
|dialogue|%>
So, looking at the first line, could each “step” be thought of as a node
in the xml? Then in the second line, are we looping through property
tags, inside of each step node, with attributes name=“preDialogues”? Is
my explanation correct, here?
And if so, what is " > array" doing?
Thank you.