Пример #1
0
  /**
   * Creates the id entity by a xml.
   *
   * @param xml the xml string
   * @return the instance of NeteaseIDEntity
   */
  private NeteaseIDEntity createEntity(String xml) {
    if (xml == null || xml.equals("")) {
      return null;
    }

    Document document = null;
    try {
      document = Dom4JReader.getDocument(xml);
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    Element rootElement = document.getRootElement();
    Element productElement = rootElement.element("product");

    NeteaseIDEntity idEntity = new NeteaseIDEntity();

    Element codeElement = productElement.element("code");
    idEntity.setCode(codeElement.getText());

    Element locationElement = productElement.element("location");
    idEntity.setLocation(locationElement.getText());

    Element birthdayElement = productElement.element("birthday");
    String birthday = birthdayElement.getText();
    birthday =
        birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
    idEntity.setBirthday(birthday);

    Element genderElement = productElement.element("gender");
    String gender = genderElement.getText();
    if (gender.equals("m")) {
      gender = UtilityLocale.getString("male");
    } else if (gender.equals("f")) {
      gender = UtilityLocale.getString("femal");
    } else {
      gender = UtilityLocale.getString("unknown");
    }
    idEntity.setGender(gender);

    return idEntity;
  }
Пример #2
0
  public ElementNode parse(File file) throws DocumentException, IOException {
    Document document = Dom4JReader.getDocument(file);

    return parse(document);
  }
Пример #3
0
  public ElementNode parse(InputStream inputStream) throws DocumentException, IOException {
    Document document = Dom4JReader.getDocument(inputStream);

    return parse(document);
  }
Пример #4
0
  public ElementNode parse(String text) throws DocumentException {
    Document document = Dom4JReader.getDocument(text);

    return parse(document);
  }