public Emulator getComandsFromXML(File file){
        Emulator emulator = new Emulator();


        try {

            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
           // Document doc = (Document) docBuilder.parse (new File(fileName));
            Document doc = (Document) docBuilder.parse (file);
            // normalize text representation
            doc.getDocumentElement ().normalize ();
          //  System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());

            NodeList inputNL = doc.getElementsByTagName("Input");

            Element inputNLElement = (Element)inputNL.item(0);

            NodeList inputNLList = inputNLElement.getChildNodes();

            String inputNLStr = inputNLList.item(0).getNodeValue().trim();
            emulator.setTape(inputNLStr);
            //String  inputNLStr = inputNL.item(0).getNodeValue();
           // Element inputNLList = (Element) inputNL.item(0);
            //String  inputNLlStr2 = inputNLList.item(0).getNodeValue().trim();
            //String input = inputNL.toString();

            NodeList listOfstates = doc.getElementsByTagName("State");
            int totalPersons = listOfstates.getLength();
          //  System.out.println("Total no of people : " + totalPersons);

            for(int s=0; s<listOfstates.getLength() ; s++){


                Node firstPersonNode = listOfstates.item(s);
                if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){


                    Element firstStateElement = (Element)firstPersonNode;

//-------
                    NodeList firstNameList = firstStateElement.getElementsByTagName("CurrentState");
                    Element firstNameElement = (Element)firstNameList.item(0);

                    NodeList textFNList = firstNameElement.getChildNodes();
                    String curStateStr = textFNList.item(0).getNodeValue().trim();
                   // String curState = textFNList.toString();
                    //String curState2 = firstNameElement.getNodeValue();

                   // String curStatelStr2 = firstNameList.item(0).getNodeValue().trim();
                    //System.out.println("First Name : " + ((Node)textFNList.item(0)).getNodeValue().trim());

//-------
                    NodeList curSymList = firstStateElement.getElementsByTagName("СurrentSymbol");
                    Element curSymElement = (Element)curSymList.item(0);
                    NodeList textLNList = curSymElement.getChildNodes();
                    String curSybmolStr = textLNList.item(0).getNodeValue().trim();
                   // System.out.println("Last Name : " + ((Node)textLNList.item(0)).getNodeValue().trim());

//----
                    NodeList newSymbList = firstStateElement.getElementsByTagName("NewSymbol");
                    Element newSymbElement = (Element)newSymbList.item(0);

                    NodeList newSymb = newSymbElement.getChildNodes();
                    String newSymbolStr = newSymb.item(0).getNodeValue().trim();
                    //System.out.println("Age : " + ((Node)textAgeList.item(0)).getNodeValue().trim());

//------
                    NodeList nextStateList = firstStateElement.getElementsByTagName("NextState");
                    Element nextStateElement = (Element)nextStateList.item(0);

                    NodeList textnextStateList = nextStateElement.getChildNodes();
                    String nextStateStr = textnextStateList .item(0).getNodeValue().trim();
//------
                    NodeList MoveDirectionList = firstStateElement.getElementsByTagName("MoveDirection");
                    Element MoveDirectionElement = (Element)MoveDirectionList.item(0);

                    NodeList textMoveDirectionList = MoveDirectionElement.getChildNodes();
                    String  moveDirStr = textMoveDirectionList.item(0).getNodeValue().trim();

                    //add to list command
                    emulator.addCmds(curStateStr,curSybmolStr,newSymbolStr,nextStateStr,moveDirStr);

                }//end of if clause


            }//end of for loop with s var


        }catch (SAXParseException err) {
/*            System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
            System.out.println(" " + err.getMessage ());*/
            err.printStackTrace();

        }catch (SAXException e) {
            Exception x = e.getException ();
            ((x == null) ? e : x).printStackTrace ();

        }catch (Throwable t) {
            t.printStackTrace ();
        }


        return emulator;



    }