code: public static String escapeXml(String orig) {
          return StringGroovyMethods.collectReplacements(orig, new Closure<String>(null) {
              public String doCall(Character arg) {
                  switch (arg) {
                      case '&':
                          return "&amp;";
                      case '<':
                          return "&lt;";
                      case '>':
                          return "&gt;";
                      case '"':
                          return "&quot;";
                      case '\'':
                          return "&apos;";
                  }
                  return null;
              }
          });
      }
docs: Escape the following characters {@code " ' & < >} with their XML entities, e.g.
  {@code "bread" & "butter"} becomes {@code &quot;bread&quot; &amp; &quot;butter&quot}.
  Notes:<ul>
  <li>Supports only the five basic XML entities (gt, lt, quot, amp, apos)</li>
  <li>Does not escape control characters</li>
  <li>Does not support DTDs or external entities</li>
  <li>Does not treat surrogate pairs specially</li>
  <li>Does not perform Unicode validation on its input</li>
  </ul>
  
  @param orig the original String
  @return A new string in which all characters that require escaping
  have been replaced with the corresponding XML entities.
  @see #escapeControlCharacters(String)