Program: 171369
Project: 171369
Buggy source:
public static void saveCharacterAsXML(GameCharacter character){
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element properties=doc.createElement("String_Node_Str");
    doc.appendChild(properties);
    Element characterCoreInfo=doc.createElement("String_Node_Str");
    Comment comment=doc.createComment("String_Node_Str");
    properties.appendChild(characterCoreInfo);
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",character.getName());
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",character.getSurname());
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",String.valueOf(character.getLevel()));
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",Main.VERSION_NUMBER);
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",String.valueOf(character.getSexualOrientation()));
    characterCoreInfo.getParentNode().insertBefore(comment,characterCoreInfo);
    Element characterCoreAttributes=doc.createElement("String_Node_Str");
    properties.appendChild(characterCoreAttributes);
    for (    Attribute att : Attribute.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCoreAttributes.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",att.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getBaseAttributeValue(att)));
    }
    Element characterPerks=doc.createElement("String_Node_Str");
    properties.appendChild(characterPerks);
    for (    Perk p : Perk.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterPerks.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",p.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.hasPerk(p)));
    }
    Element characterFetishes=doc.createElement("String_Node_Str");
    properties.appendChild(characterFetishes);
    for (    Fetish f : Fetish.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterFetishes.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",f.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.hasFetish(f)));
    }
    Element characterStatusEffects=doc.createElement("String_Node_Str");
    properties.appendChild(characterStatusEffects);
    for (    StatusEffect se : character.getStatusEffects()) {
      Element element=doc.createElement("String_Node_Str");
      characterStatusEffects.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",se.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getStatusEffectDuration(se)));
    }
    Element characterCombat=doc.createElement("String_Node_Str");
    properties.appendChild(characterCombat);
    for (    Spell s : Spell.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCombat.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",s.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getSpells().contains(s)));
    }
    for (    SpecialAttack sa : SpecialAttack.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCombat.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",sa.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getSpecialAttacks().contains(sa)));
    }
    Element characterBody=doc.createElement("String_Node_Str");
    properties.appendChild(characterBody);
    Element bodyCore=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyCore);
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.isPiercedNavel()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getHeightValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getFemininityValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getBodySizeValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getMuscleValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getPubicHair()));
    for (    BodyCoveringType bct : BodyCoveringType.values()) {
      Element element=doc.createElement("String_Node_Str");
      bodyCore.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",bct.toString());
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getPattern().toString());
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getPrimaryColour().toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getCovering(bct).isPrimaryGlowing()));
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getSecondaryColour().toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getCovering(bct).isSecondaryGlowing()));
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getBodyCoveringTypesDiscovered().contains(bct)));
    }
    Element bodyAntennae=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAntennae);
    addAttribute(doc,bodyAntennae,"String_Node_Str",character.getAntennaType().toString());
    addAttribute(doc,bodyAntennae,"String_Node_Str",String.valueOf(character.getAntennaRows()));
    Element bodyArm=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyArm);
    addAttribute(doc,bodyArm,"String_Node_Str",character.getArmType().toString());
    addAttribute(doc,bodyArm,"String_Node_Str",String.valueOf(character.getArmRows()));
    addAttribute(doc,bodyArm,"String_Node_Str",character.getUnderarmHair().toString());
    Element bodyAss=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAss);
    addAttribute(doc,bodyAss,"String_Node_Str",character.getAssType().toString());
    addAttribute(doc,bodyAss,"String_Node_Str",String.valueOf(character.getAssSize().getValue()));
    addAttribute(doc,bodyAss,"String_Node_Str",String.valueOf(character.getHipSize().getValue()));
    Element bodyAnus=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAnus);
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssWetness().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssElasticity().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssPlasticity().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssRawCapacityValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssStretchedCapacity()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.isAssVirgin()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.isAssBleached()));
    addAttribute(doc,bodyAnus,"String_Node_Str",character.getAssHair().toString());
    Element anusModifiers=doc.createElement("String_Node_Str");
    bodyAnus.appendChild(anusModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,anusModifiers,om.toString(),String.valueOf(character.hasAssOrificeModifier(om)));
    }
    Element bodyBreast=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyBreast);
    addAttribute(doc,bodyBreast,"String_Node_Str",character.getBreastType().toString());
    addAttribute(doc,bodyBreast,"String_Node_Str",character.getBreastShape().toString());
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastSize().getMeasurement()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastRows()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastRawLactationValue()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getNippleCountPerBreast()));
    Element bodyNipple=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyNipple);
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleElasticity().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNipplePlasticity().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleRawCapacityValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleStretchedCapacity()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.isNippleVirgin()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.isPiercedNipple()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleSize().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleShape()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getAreolaeSize().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getAreolaeShape()));
    Element nippleModifiers=doc.createElement("String_Node_Str");
    bodyNipple.appendChild(nippleModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,nippleModifiers,om.toString(),String.valueOf(character.hasNippleOrificeModifier(om)));
    }
    Element bodyMilk=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyMilk);
    addAttribute(doc,bodyMilk,"String_Node_Str",String.valueOf(character.getMilkFlavour()));
    Element milkModifiers=doc.createElement("String_Node_Str");
    bodyMilk.appendChild(milkModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,milkModifiers,fm.toString(),String.valueOf(character.hasMilkModifier(fm)));
    }
    Element bodyEar=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyEar);
    addAttribute(doc,bodyEar,"String_Node_Str",character.getEarType().toString());
    addAttribute(doc,bodyEar,"String_Node_Str",String.valueOf(character.isPiercedEar()));
    Element bodyEye=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyEye);
    addAttribute(doc,bodyEye,"String_Node_Str",character.getEyeType().toString());
    addAttribute(doc,bodyEye,"String_Node_Str",String.valueOf(character.getEyePairs()));
    addAttribute(doc,bodyEye,"String_Node_Str",character.getIrisShape().toString());
    addAttribute(doc,bodyEye,"String_Node_Str",character.getPupilShape().toString());
    Element bodyFace=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyFace);
    addAttribute(doc,bodyFace,"String_Node_Str",character.getFaceType().toString());
    addAttribute(doc,bodyFace,"String_Node_Str",String.valueOf(character.isPiercedNose()));
    addAttribute(doc,bodyFace,"String_Node_Str",character.getFacialHair().toString());
    Element bodyMouth=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyMouth);
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceElasticity().getValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFacePlasticity().getValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceRawCapacityValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceStretchedCapacity()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.isFaceVirgin()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.isPiercedLip()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getLipSizeValue()));
    Element mouthModifiers=doc.createElement("String_Node_Str");
    bodyMouth.appendChild(mouthModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,mouthModifiers,om.toString(),String.valueOf(character.hasFaceOrificeModifier(om)));
    }
    Element bodyTongue=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTongue);
    addAttribute(doc,bodyTongue,"String_Node_Str",String.valueOf(character.isPiercedTongue()));
    addAttribute(doc,bodyTongue,"String_Node_Str",String.valueOf(character.getTongueLengthValue()));
    Element tongueModifiers=doc.createElement("String_Node_Str");
    bodyTongue.appendChild(tongueModifiers);
    for (    TongueModifier tm : TongueModifier.values()) {
      addAttribute(doc,tongueModifiers,tm.toString(),String.valueOf(character.hasTongueModifier(tm)));
    }
    Element bodyHair=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyHair);
    addAttribute(doc,bodyHair,"String_Node_Str",character.getHairType().toString());
    addAttribute(doc,bodyHair,"String_Node_Str",String.valueOf(character.getHairRawLengthValue()));
    addAttribute(doc,bodyHair,"String_Node_Str",character.getHairStyle().toString());
    Element bodyHorn=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyHorn);
    addAttribute(doc,bodyHorn,"String_Node_Str",character.getHornType().toString());
    addAttribute(doc,bodyHorn,"String_Node_Str",String.valueOf(character.getHornRows()));
    Element bodyLeg=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyLeg);
    addAttribute(doc,bodyLeg,"String_Node_Str",character.getLegType().toString());
    Element bodyPenis=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyPenis);
    addAttribute(doc,bodyPenis,"String_Node_Str",character.getPenisType().toString());
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisRawSizeValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.isPiercedPenis()));
    Element penisModifiers=doc.createElement("String_Node_Str");
    bodyPenis.appendChild(penisModifiers);
    for (    PenisModifier pm : PenisModifier.values()) {
      addAttribute(doc,penisModifiers,pm.toString(),String.valueOf(character.hasPenisModifier(pm)));
    }
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getUrethraElasticity().getValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getUrethraPlasticity().getValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisRawCapacityValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisStretchedCapacity()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.isUrethraVirgin()));
    Element urethraModifiers=doc.createElement("String_Node_Str");
    bodyPenis.appendChild(urethraModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,urethraModifiers,om.toString(),String.valueOf(character.hasUrethraOrificeModifier(om)));
    }
    Element bodyTesticle=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTesticle);
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getTesticleSize().getValue()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getPenisRawCumProductionValue()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getPenisNumberOfTesticles()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.isInternalTesticles()));
    Element bodyCum=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyCum);
    addAttribute(doc,bodyCum,"String_Node_Str",String.valueOf(character.getCumFlavour()));
    Element cumModifiers=doc.createElement("String_Node_Str");
    bodyCum.appendChild(cumModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,cumModifiers,fm.toString(),String.valueOf(character.hasCumModifier(fm)));
    }
    Element bodySkin=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodySkin);
    addAttribute(doc,bodySkin,"String_Node_Str",character.getSkinType().toString());
    Element bodyTail=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTail);
    addAttribute(doc,bodyTail,"String_Node_Str",character.getTailType().toString());
    addAttribute(doc,bodyTail,"String_Node_Str",String.valueOf(character.getTailCount()));
    Element bodyVagina=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyVagina);
    addAttribute(doc,bodyVagina,"String_Node_Str",character.getVaginaType().toString());
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawLabiaSizeValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawClitorisSizeValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.isPiercedVagina()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaWetness().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaElasticity().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaPlasticity().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawCapacityValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaStretchedCapacity()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.isVaginaVirgin()));
    Element vaginaModifiers=doc.createElement("String_Node_Str");
    bodyVagina.appendChild(vaginaModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,vaginaModifiers,om.toString(),String.valueOf(character.hasVaginaOrificeModifier(om)));
    }
    Element bodyGirlcum=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyGirlcum);
    addAttribute(doc,bodyGirlcum,"String_Node_Str",String.valueOf(character.getGirlcumFlavour()));
    Element girlcumModifiers=doc.createElement("String_Node_Str");
    bodyGirlcum.appendChild(girlcumModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,girlcumModifiers,fm.toString(),String.valueOf(character.hasGirlcumModifier(fm)));
    }
    Element bodyWing=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyWing);
    addAttribute(doc,bodyWing,"String_Node_Str",character.getWingType().toString());
    Element characterPlayerCoreInfo=doc.createElement("String_Node_Str");
    properties.appendChild(characterPlayerCoreInfo);
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getExperience()));
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getLevelUpPoints()));
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getPerkPoints()));
    Element characterSexStats=doc.createElement("String_Node_Str");
    properties.appendChild(characterSexStats);
    Element characterCumCount=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterCumCount);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        Element element=doc.createElement("String_Node_Str");
        characterCumCount.appendChild(element);
        addAttribute(doc,element,"String_Node_Str",pt.toString());
        addAttribute(doc,element,"String_Node_Str",ot.toString());
        addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getCumCount(new SexType(pt,ot))));
      }
    }
    Element characterSexCount=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterSexCount);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        Element element=doc.createElement("String_Node_Str");
        characterSexCount.appendChild(element);
        addAttribute(doc,element,"String_Node_Str",pt.toString());
        addAttribute(doc,element,"String_Node_Str",ot.toString());
        addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getSexCount(new SexType(pt,ot))));
      }
    }
    Element characterVirginityTakenBy=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterVirginityTakenBy);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        if (((PlayerCharacter)character).getVirginityLoss(new SexType(pt,ot)) != null) {
          Element element=doc.createElement("String_Node_Str");
          characterVirginityTakenBy.appendChild(element);
          addAttribute(doc,element,"String_Node_Str",pt.toString());
          addAttribute(doc,element,"String_Node_Str",ot.toString());
          addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getVirginityLoss(new SexType(pt,ot))));
        }
      }
    }
    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer transformer1=tf.newTransformer();
    transformer1.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    StringWriter writer=new StringWriter();
    transformer1.transform(new DOMSource(doc),new StreamResult(writer));
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    File dir=new File("String_Node_Str");
    dir.mkdir();
    File dirCharacter=new File("String_Node_Str");
    dirCharacter.mkdir();
    int saveNumber=0;
    String saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str";
    if (new File("String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str").exists())     saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    while (new File("String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str").exists()) {
      saveNumber++;
      saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    }
    StreamResult result=new StreamResult(new File(saveLocation));
    transformer.transform(source,result);
  }
 catch (  ParserConfigurationException pce) {
    pce.printStackTrace();
  }
catch (  TransformerException tfe) {
    tfe.printStackTrace();
  }
}

Fixed version (ground truth):
public static void saveCharacterAsXML(GameCharacter character){
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element properties=doc.createElement("String_Node_Str");
    doc.appendChild(properties);
    Element characterCoreInfo=doc.createElement("String_Node_Str");
    Comment comment=doc.createComment("String_Node_Str");
    properties.appendChild(characterCoreInfo);
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",character.getName());
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",character.getSurname());
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",String.valueOf(character.getLevel()));
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",Main.VERSION_NUMBER);
    createXMLElementWithValue(doc,characterCoreInfo,"String_Node_Str",String.valueOf(character.getSexualOrientation()));
    characterCoreInfo.getParentNode().insertBefore(comment,characterCoreInfo);
    Element characterCoreAttributes=doc.createElement("String_Node_Str");
    properties.appendChild(characterCoreAttributes);
    for (    Attribute att : Attribute.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCoreAttributes.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",att.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getBaseAttributeValue(att)));
    }
    Element characterPerks=doc.createElement("String_Node_Str");
    properties.appendChild(characterPerks);
    for (    Perk p : Perk.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterPerks.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",p.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.hasPerk(p)));
    }
    Element characterFetishes=doc.createElement("String_Node_Str");
    properties.appendChild(characterFetishes);
    for (    Fetish f : Fetish.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterFetishes.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",f.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.hasFetish(f)));
    }
    Element characterStatusEffects=doc.createElement("String_Node_Str");
    properties.appendChild(characterStatusEffects);
    for (    StatusEffect se : character.getStatusEffects()) {
      Element element=doc.createElement("String_Node_Str");
      characterStatusEffects.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",se.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getStatusEffectDuration(se)));
    }
    Element characterCombat=doc.createElement("String_Node_Str");
    properties.appendChild(characterCombat);
    for (    Spell s : Spell.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCombat.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",s.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getSpells().contains(s)));
    }
    for (    SpecialAttack sa : SpecialAttack.values()) {
      Element element=doc.createElement("String_Node_Str");
      characterCombat.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",sa.toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getSpecialAttacks().contains(sa)));
    }
    Element characterBody=doc.createElement("String_Node_Str");
    properties.appendChild(characterBody);
    Element bodyCore=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyCore);
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.isPiercedNavel()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getHeightValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getFemininityValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getBodySizeValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getMuscleValue()));
    addAttribute(doc,bodyCore,"String_Node_Str",String.valueOf(character.getPubicHair()));
    for (    BodyCoveringType bct : BodyCoveringType.values()) {
      Element element=doc.createElement("String_Node_Str");
      bodyCore.appendChild(element);
      addAttribute(doc,element,"String_Node_Str",bct.toString());
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getPattern().toString());
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getPrimaryColour().toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getCovering(bct).isPrimaryGlowing()));
      addAttribute(doc,element,"String_Node_Str",character.getCovering(bct).getSecondaryColour().toString());
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getCovering(bct).isSecondaryGlowing()));
      addAttribute(doc,element,"String_Node_Str",String.valueOf(character.getBodyCoveringTypesDiscovered().contains(bct)));
    }
    Element bodyAntennae=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAntennae);
    addAttribute(doc,bodyAntennae,"String_Node_Str",character.getAntennaType().toString());
    addAttribute(doc,bodyAntennae,"String_Node_Str",String.valueOf(character.getAntennaRows()));
    Element bodyArm=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyArm);
    addAttribute(doc,bodyArm,"String_Node_Str",character.getArmType().toString());
    addAttribute(doc,bodyArm,"String_Node_Str",String.valueOf(character.getArmRows()));
    addAttribute(doc,bodyArm,"String_Node_Str",character.getUnderarmHair().toString());
    Element bodyAss=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAss);
    addAttribute(doc,bodyAss,"String_Node_Str",character.getAssType().toString());
    addAttribute(doc,bodyAss,"String_Node_Str",String.valueOf(character.getAssSize().getValue()));
    addAttribute(doc,bodyAss,"String_Node_Str",String.valueOf(character.getHipSize().getValue()));
    Element bodyAnus=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyAnus);
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssWetness().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssElasticity().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssPlasticity().getValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssRawCapacityValue()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.getAssStretchedCapacity()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.isAssVirgin()));
    addAttribute(doc,bodyAnus,"String_Node_Str",String.valueOf(character.isAssBleached()));
    addAttribute(doc,bodyAnus,"String_Node_Str",character.getAssHair().toString());
    Element anusModifiers=doc.createElement("String_Node_Str");
    bodyAnus.appendChild(anusModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,anusModifiers,om.toString(),String.valueOf(character.hasAssOrificeModifier(om)));
    }
    Element bodyBreast=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyBreast);
    addAttribute(doc,bodyBreast,"String_Node_Str",character.getBreastType().toString());
    addAttribute(doc,bodyBreast,"String_Node_Str",character.getBreastShape().toString());
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastSize().getMeasurement()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastRows()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getBreastRawLactationValue()));
    addAttribute(doc,bodyBreast,"String_Node_Str",String.valueOf(character.getNippleCountPerBreast()));
    Element bodyNipple=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyNipple);
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleElasticity().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNipplePlasticity().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleRawCapacityValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleStretchedCapacity()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.isNippleVirgin()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.isPiercedNipple()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleSize().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getNippleShape()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getAreolaeSize().getValue()));
    addAttribute(doc,bodyNipple,"String_Node_Str",String.valueOf(character.getAreolaeShape()));
    Element nippleModifiers=doc.createElement("String_Node_Str");
    bodyNipple.appendChild(nippleModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,nippleModifiers,om.toString(),String.valueOf(character.hasNippleOrificeModifier(om)));
    }
    Element bodyMilk=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyMilk);
    addAttribute(doc,bodyMilk,"String_Node_Str",String.valueOf(character.getMilkFlavour()));
    Element milkModifiers=doc.createElement("String_Node_Str");
    bodyMilk.appendChild(milkModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,milkModifiers,fm.toString(),String.valueOf(character.hasMilkModifier(fm)));
    }
    Element bodyEar=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyEar);
    addAttribute(doc,bodyEar,"String_Node_Str",character.getEarType().toString());
    addAttribute(doc,bodyEar,"String_Node_Str",String.valueOf(character.isPiercedEar()));
    Element bodyEye=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyEye);
    addAttribute(doc,bodyEye,"String_Node_Str",character.getEyeType().toString());
    addAttribute(doc,bodyEye,"String_Node_Str",String.valueOf(character.getEyePairs()));
    addAttribute(doc,bodyEye,"String_Node_Str",character.getIrisShape().toString());
    addAttribute(doc,bodyEye,"String_Node_Str",character.getPupilShape().toString());
    Element bodyFace=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyFace);
    addAttribute(doc,bodyFace,"String_Node_Str",character.getFaceType().toString());
    addAttribute(doc,bodyFace,"String_Node_Str",String.valueOf(character.isPiercedNose()));
    addAttribute(doc,bodyFace,"String_Node_Str",character.getFacialHair().toString());
    Element bodyMouth=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyMouth);
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceElasticity().getValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFacePlasticity().getValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceRawCapacityValue()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getFaceStretchedCapacity()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.isFaceVirgin()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.isPiercedLip()));
    addAttribute(doc,bodyMouth,"String_Node_Str",String.valueOf(character.getLipSizeValue()));
    Element mouthModifiers=doc.createElement("String_Node_Str");
    bodyMouth.appendChild(mouthModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,mouthModifiers,om.toString(),String.valueOf(character.hasFaceOrificeModifier(om)));
    }
    Element bodyTongue=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTongue);
    addAttribute(doc,bodyTongue,"String_Node_Str",String.valueOf(character.isPiercedTongue()));
    addAttribute(doc,bodyTongue,"String_Node_Str",String.valueOf(character.getTongueLengthValue()));
    Element tongueModifiers=doc.createElement("String_Node_Str");
    bodyTongue.appendChild(tongueModifiers);
    for (    TongueModifier tm : TongueModifier.values()) {
      addAttribute(doc,tongueModifiers,tm.toString(),String.valueOf(character.hasTongueModifier(tm)));
    }
    Element bodyHair=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyHair);
    addAttribute(doc,bodyHair,"String_Node_Str",character.getHairType().toString());
    addAttribute(doc,bodyHair,"String_Node_Str",String.valueOf(character.getHairRawLengthValue()));
    addAttribute(doc,bodyHair,"String_Node_Str",character.getHairStyle().toString());
    Element bodyHorn=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyHorn);
    addAttribute(doc,bodyHorn,"String_Node_Str",character.getHornType().toString());
    addAttribute(doc,bodyHorn,"String_Node_Str",String.valueOf(character.getHornRows()));
    Element bodyLeg=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyLeg);
    addAttribute(doc,bodyLeg,"String_Node_Str",character.getLegType().toString());
    Element bodyPenis=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyPenis);
    addAttribute(doc,bodyPenis,"String_Node_Str",character.getPenisType().toString());
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisRawSizeValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.isPiercedPenis()));
    Element penisModifiers=doc.createElement("String_Node_Str");
    bodyPenis.appendChild(penisModifiers);
    for (    PenisModifier pm : PenisModifier.values()) {
      addAttribute(doc,penisModifiers,pm.toString(),String.valueOf(character.hasPenisModifier(pm)));
    }
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getUrethraElasticity().getValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getUrethraPlasticity().getValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisRawCapacityValue()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.getPenisStretchedCapacity()));
    addAttribute(doc,bodyPenis,"String_Node_Str",String.valueOf(character.isUrethraVirgin()));
    Element urethraModifiers=doc.createElement("String_Node_Str");
    bodyPenis.appendChild(urethraModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,urethraModifiers,om.toString(),String.valueOf(character.hasUrethraOrificeModifier(om)));
    }
    Element bodyTesticle=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTesticle);
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getTesticleSize().getValue()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getPenisRawCumProductionValue()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.getPenisNumberOfTesticles()));
    addAttribute(doc,bodyTesticle,"String_Node_Str",String.valueOf(character.isInternalTesticles()));
    Element bodyCum=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyCum);
    addAttribute(doc,bodyCum,"String_Node_Str",String.valueOf(character.getCumFlavour()));
    Element cumModifiers=doc.createElement("String_Node_Str");
    bodyCum.appendChild(cumModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,cumModifiers,fm.toString(),String.valueOf(character.hasCumModifier(fm)));
    }
    Element bodySkin=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodySkin);
    addAttribute(doc,bodySkin,"String_Node_Str",character.getSkinType().toString());
    Element bodyTail=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyTail);
    addAttribute(doc,bodyTail,"String_Node_Str",character.getTailType().toString());
    addAttribute(doc,bodyTail,"String_Node_Str",String.valueOf(character.getTailCount()));
    Element bodyVagina=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyVagina);
    addAttribute(doc,bodyVagina,"String_Node_Str",character.getVaginaType().toString());
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawLabiaSizeValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawClitorisSizeValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.isPiercedVagina()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaWetness().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaElasticity().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaPlasticity().getValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaRawCapacityValue()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.getVaginaStretchedCapacity()));
    addAttribute(doc,bodyVagina,"String_Node_Str",String.valueOf(character.isVaginaVirgin()));
    Element vaginaModifiers=doc.createElement("String_Node_Str");
    bodyVagina.appendChild(vaginaModifiers);
    for (    OrificeModifier om : OrificeModifier.values()) {
      addAttribute(doc,vaginaModifiers,om.toString(),String.valueOf(character.hasVaginaOrificeModifier(om)));
    }
    Element bodyGirlcum=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyGirlcum);
    addAttribute(doc,bodyGirlcum,"String_Node_Str",String.valueOf(character.getGirlcumFlavour()));
    Element girlcumModifiers=doc.createElement("String_Node_Str");
    bodyGirlcum.appendChild(girlcumModifiers);
    for (    FluidModifier fm : FluidModifier.values()) {
      addAttribute(doc,girlcumModifiers,fm.toString(),String.valueOf(character.hasGirlcumModifier(fm)));
    }
    Element bodyWing=doc.createElement("String_Node_Str");
    characterBody.appendChild(bodyWing);
    addAttribute(doc,bodyWing,"String_Node_Str",character.getWingType().toString());
    Element characterPlayerCoreInfo=doc.createElement("String_Node_Str");
    properties.appendChild(characterPlayerCoreInfo);
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getExperience()));
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getLevelUpPoints()));
    createXMLElementWithValue(doc,characterPlayerCoreInfo,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getPerkPoints()));
    Element characterSexStats=doc.createElement("String_Node_Str");
    properties.appendChild(characterSexStats);
    Element characterCumCount=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterCumCount);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        Element element=doc.createElement("String_Node_Str");
        characterCumCount.appendChild(element);
        addAttribute(doc,element,"String_Node_Str",pt.toString());
        addAttribute(doc,element,"String_Node_Str",ot.toString());
        addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getCumCount(new SexType(pt,ot))));
      }
    }
    Element characterSexCount=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterSexCount);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        Element element=doc.createElement("String_Node_Str");
        characterSexCount.appendChild(element);
        addAttribute(doc,element,"String_Node_Str",pt.toString());
        addAttribute(doc,element,"String_Node_Str",ot.toString());
        addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getSexCount(new SexType(pt,ot))));
      }
    }
    Element characterVirginityTakenBy=doc.createElement("String_Node_Str");
    characterSexStats.appendChild(characterVirginityTakenBy);
    for (    PenetrationType pt : PenetrationType.values()) {
      for (      OrificeType ot : OrificeType.values()) {
        if (((PlayerCharacter)character).getVirginityLoss(new SexType(pt,ot)) != null) {
          Element element=doc.createElement("String_Node_Str");
          characterVirginityTakenBy.appendChild(element);
          addAttribute(doc,element,"String_Node_Str",pt.toString());
          addAttribute(doc,element,"String_Node_Str",ot.toString());
          addAttribute(doc,element,"String_Node_Str",String.valueOf(((PlayerCharacter)character).getVirginityLoss(new SexType(pt,ot))));
        }
      }
    }
    Element characterInventory=doc.createElement("String_Node_Str");
    properties.appendChild(characterInventory);
    createXMLElementWithValue(doc,characterInventory,"String_Node_Str",String.valueOf(character.getMoney()));
    createXMLElementWithValue(doc,characterInventory,"String_Node_Str",String.valueOf(character.getEssenceCount(TFEssence.ARCANE)));
    if (character.getMainWeapon() != null) {
      Element mainWeapon=doc.createElement("String_Node_Str");
      characterInventory.appendChild(mainWeapon);
      character.getMainWeapon().saveAsXML(mainWeapon,doc);
    }
    if (character.getOffhandWeapon() != null) {
      Element offhandWeapon=doc.createElement("String_Node_Str");
      characterInventory.appendChild(offhandWeapon);
      character.getOffhandWeapon().saveAsXML(offhandWeapon,doc);
    }
    Element clothingEquipped=doc.createElement("String_Node_Str");
    characterInventory.appendChild(clothingEquipped);
    for (    AbstractClothing clothing : character.getClothingCurrentlyEquipped()) {
      clothing.saveAsXML(clothingEquipped,doc);
    }
    Element itemsInInventory=doc.createElement("String_Node_Str");
    characterInventory.appendChild(itemsInInventory);
    for (    Entry<AbstractItem,Integer> item : character.getMapOfDuplicateItems().entrySet()) {
      Element e=item.getKey().saveAsXML(itemsInInventory,doc);
      addAttribute(doc,e,"String_Node_Str",String.valueOf(item.getValue()));
    }
    Element clothingInInventory=doc.createElement("String_Node_Str");
    characterInventory.appendChild(clothingInInventory);
    for (    Entry<AbstractClothing,Integer> clothing : character.getMapOfDuplicateClothing().entrySet()) {
      Element e=clothing.getKey().saveAsXML(clothingInInventory,doc);
      addAttribute(doc,e,"String_Node_Str",String.valueOf(clothing.getValue()));
    }
    Element weaponsInInventory=doc.createElement("String_Node_Str");
    characterInventory.appendChild(weaponsInInventory);
    for (    Entry<AbstractWeapon,Integer> weapon : character.getMapOfDuplicateWeapons().entrySet()) {
      Element e=weapon.getKey().saveAsXML(weaponsInInventory,doc);
      addAttribute(doc,e,"String_Node_Str",String.valueOf(weapon.getValue()));
    }
    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer transformer1=tf.newTransformer();
    transformer1.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    StringWriter writer=new StringWriter();
    transformer1.transform(new DOMSource(doc),new StreamResult(writer));
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    File dir=new File("String_Node_Str");
    dir.mkdir();
    File dirCharacter=new File("String_Node_Str");
    dirCharacter.mkdir();
    int saveNumber=0;
    String saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str";
    if (new File("String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str").exists())     saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    while (new File("String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str").exists()) {
      saveNumber++;
      saveLocation="String_Node_Str" + character.getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    }
    StreamResult result=new StreamResult(new File(saveLocation));
    transformer.transform(source,result);
  }
 catch (  ParserConfigurationException pce) {
    pce.printStackTrace();
  }
catch (  TransformerException tfe) {
    tfe.printStackTrace();
  }
}