code: private boolean isValid(CharSequence text) {
          for (int i = 0; i < text.length(); i++) {
              char c = text.charAt(i);
              // as defined by http://www.w3.org/TR/REC-xml/#charsets.
              boolean valid = c == 0x9 || c == 0xA || c == 0xD
                      || (c >= 0x20 && c <= 0xd7ff)
                      || (c >= 0xe000 && c <= 0xfffd);
              if (!valid) {
                  return false;
              }
          }
          return true;
      }
docs: Returns true if all of the characters in the text are permitted for use
  in XML documents.