code: public static Monomer getMonomer(Element monomer) throws MonomerException {
      Monomer m = new Monomer();
      Namespace ns = monomer.getNamespace();
      m.setAlternateId(monomer.getChildText(MONOMER_ID_ELEMENT, ns));
      m.setCanSMILES(monomer.getChildText(MONOMER_SMILES_ELEMENT, ns));
      String encodedMolfile = monomer.getChildText(MONOMER_MOL_FILE_ELEMENT, ns);
  
      String molfile = null;
      try {
        molfile = MolfileEncoder.decode(encodedMolfile);
      } catch (EncoderException ex) {
        throw new MonomerException("Invalid monomer molfile");
      }
      m.setMolfile(molfile);
      m.setMonomerType(monomer.getChildText(MONOMER_TYPE_ELEMENT, ns));
      m.setPolymerType(monomer.getChildText(POLYMER_TYPE_ELEMENT, ns));
      m.setNaturalAnalog(monomer.getChildText(NATURAL_ANALOG_ELEMENT, ns));
      m.setName(monomer.getChildText(MONOMER_NAME_ELEMENT, ns));
      Element attachmentElement = monomer.getChild(ATTACHEMENTS_ELEMENT, ns);
  
      if (null != attachmentElement) {
        List attachments = attachmentElement.getChildren(ATTACHEMENT_ELEMENT, ns);
        List<Attachment> l = new ArrayList<Attachment>();
        Iterator i = attachments.iterator();
        while (i.hasNext()) {
          Element attachment = (Element) i.next();
          Attachment att = getAttachment(attachment);
          l.add(att);
        }
        m.setAttachmentList(l);
      }
      return m;
    }
docs: Convert monomer element to Monomer object
  
  @param monomer element
  @return Monomer
  @throws MonomerException if element is not a valid monomer