public  static void printNewUserToXMLFile(String userName, String password, String id){

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = null;
        Document doc = null;
        try {
            db = dbf.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
        InputStream is = null;
        try {
            is = new FileInputStream("users.xml");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            doc = db.parse(is);
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Node users = doc.getFirstChild();

        Element userEl = doc.createElement(NODE_USER);
        Element usernameEl = doc.createElement(NODE_USERNAME);
        usernameEl.appendChild(doc.createTextNode(userName));
        userEl.appendChild(usernameEl);
        Element passwordEl = doc.createElement(NODE_PASSWORD);
        passwordEl.appendChild(doc.createTextNode(password));
        userEl.appendChild(passwordEl);
        Element idEl = doc.createElement(NODE_ID);
        idEl.appendChild(doc.createTextNode(id));
        userEl.appendChild(idEl);

        users.appendChild(userEl);

        try{
            OutputFormat format = new OutputFormat(doc);
            format.setIndenting(true);
            XMLSerializer serializer = new XMLSerializer(
                    new FileOutputStream(new File("users.xml")),format);

            serializer.serialize(doc);

        }catch (IOException e){
            e.printStackTrace();
        }
    }