Why don't you use `pushSerializeAndPop` and pass it the whole `rings` array, instead of manually looping here?
```js
var nodeName;
var nodeFactory = function() {
  nodeName = goog.isDef('nodeName') ? 'interior' : 'exterior';
  return ol.xml.createElementNS(node.namespaceURI, nodeName);
};
ol.xml.pushSerializeAndPop(
    {node: node, srsName: srsName, writeSrsName: false},
    ol.format.GML.RING_SERIALIZERS_, nodeFactory, rings[i], objectStack);
```