public void writeFlightReportToXML(FlightReport report) {
        try {
            
              if(!fileWriter.checkIfFileExistsOrCreateNew(FlightReportPath)){
                createFlightReportToXMLFile(report);
            }
            
            // create document from existing file
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(FlightReportPath);
            Element reportElement = doc.getDocumentElement();
            
            // set data to root - element
            Attr ReportDate = doc.createAttribute("date");
            ReportDate.setValue(report.getDateStamp().toString());
            reportElement.setAttributeNode(ReportDate);
                  
            // flightroute elements
            Element flightrouteElement = doc.createElement("flightroute");
            reportElement.appendChild(flightrouteElement);
            for (int i = 0; i < report.getAllFlights().size(); i++) {
            // set attribute to Flighroute element:
                Attr idAttribute = doc.createAttribute("id");
                idAttribute.setValue(report.getAllFlights().get(i).getFlightRoute().getFlightRouteNr());
                flightrouteElement.setAttributeNode(idAttribute);

                Attr destinationAttribute = doc.createAttribute("destination");
                destinationAttribute.setValue(report.getAllFlights().get(i).getFlightRoute().getDestination());
                flightrouteElement.setAttributeNode(destinationAttribute);

                      //set ID attribute to Trolley element:
                for (int j = 0; j < report.getAllFlights().get(i).getTrolleysOnFlight().size(); j++) {
                    // trolley elements
                    Element trolleyElement = doc.createElement("trolley");
                    flightrouteElement.appendChild(trolleyElement);
                    Attr trolleyIdAttribute = doc.createAttribute("id");
                    trolleyIdAttribute.setValue(report.getAllFlights().get(i).getTrolleysOnFlight().get(j).getTrolleyId() + "");
                    trolleyElement.setAttributeNode(trolleyIdAttribute);

                    Attr trolleyTotalWeightAttribute = doc.createAttribute("payload");
                    trolleyTotalWeightAttribute.setValue(report.getAllFlights().get(i).getTrolleysOnFlight().get(j).getPayLoad()+ "");
                    trolleyElement.setAttributeNode(trolleyTotalWeightAttribute);
                }
            }
            TransformAndFormatXML(doc);
            
        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (TransformerException tfe) {
            tfe.printStackTrace();
        } catch (SAXException ex) {
            Logger.getLogger(XMLFileParser.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(XMLFileParser.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        
    }