code: public void checkSimpleXMLString(String xml) throws IOException {
      Pattern pattern = Pattern.compile("(<error.*?/>)", Pattern.DOTALL|Pattern.MULTILINE);
      Matcher matcher = pattern.matcher(xml);
      int pos = 0;
      while (matcher.find(pos)) {
        String errorElement = matcher.group();
        pos = matcher.end();
        if (errorElement.contains("\n") || errorElement.contains("\r")) {
          throw new IOException("<error ...> may not contain line breaks");
        }
        char beforeError = xml.charAt(matcher.start()-1);
        if (beforeError != '\n' && beforeError != '\r') {
          throw new IOException("Each <error ...> must start on a new line");
        }
      }
    }
docs: Check some limits of our simplified XML output.