Please don't just "use my code". Your XML file is different from the block I used, in that I only have one host and you have several.
The key point (I'm sorry if it wasn't clear) I was making was that
returns a reference to an array when there is more than one element with the same name. You need to either differentiate between the "singular" and the "plural" using
returns depends on the XML it parses. I think that's the crux of your problem.