Changes in the logic, added tests and example to generate XML alternating nodes