code: public static String trim(String xml) {
          String content = removeDeclaration(xml);
          return trimElements(content);
      }
docs: Removes both XML declaration and trims all elements.
  @param xml XML to trim.
  @return trimmed version.