a array like this:
a = ["<root>",
"<products>",
"<product>",
"<id>", "1", "</id>",
"<name>", "name1", "</name>",
"</product>",
"<product>",
"<id>", "2", "</id>",
"<name>", "name2", "</name>",
"</product>",
"</products>",
"</root>"]
and a hash like this:
b = {
"products" => {
"product" => [
{"id" => "1", "name" => "name1"},
{"id" => "2", "name" => "name2"}
]
}
}
How to get this hash c out of a and b :
c = {
"products" => {
"product" => [
{"id" => "1", "name" => "name1", "id_index" => 4, "name_index" => 7},
{"id" => "2", "name" => "name2", "id_index" => 12, "name_index" => 15}
]
}
}
4, 7, 12, 15 are indexes of “1”, “name1”, “2”, “name2” in the array a.
I guess it would look like: