Refactor: Use pcmk__xe_foreach_child in more places.
This replaces several - but not all - uses of pcmk__xml_first_child in a
loop. There are a bunch of other loops that are unsuitable for
conversion: they use so many variables from outside the loop that it
would be annoying, or they build up some hash table or other structure
as they go, or they call a single function but that function doesn't
return a value and it doesn't make sense to modify them to do so.
This patch looks more complicated than it is. It's basically just
moving the bodies of loops into their own functions.