All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.akhikhl.wuff.XmlUtils.groovy Maven / Gradle / Ivy

/*
 * wuff
 *
 * Copyright 2014  Andrey Hihlovskiy.
 *
 * See the file "LICENSE" for copying and usage permission.
 */
package org.akhikhl.wuff

import groovy.xml.MarkupBuilder

/**
 *
 * @author akhikhl
 */
class XmlUtils {

  /**
   * writes the specified node recursively to the given builder.
   * @param builder - destination xml builder
   * @param node - node to write to the builder, can be groovy.util.Node or String
   */
  static void writeNode(MarkupBuilder builder, node) {
    if(node instanceof String)
      builder.mkp.yield node
    else
      builder.invokeMethod node.name(), [ node.attributes(), {
        node.children().each {
          XmlUtils.writeNode(builder, it)
        }
      } ]
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy