Hello everybody,
Does anyone know why document.getXMLEncoding() always return null in my code ?

thanks :-)

        Document document = DocumentHelper.createDocument();

        Element rootElement = document.addElement("root");
       
        Element testNode = rootElement.addElement("testNode").addAttribute("name","Praveen");
        Element author1 = rootElement.addElement ("author").addAttribute("name","James").addAttribute("location","UK").addText("James Strachan");

        author1 = rootElement.addElement("author").addAttribute("name","James").addAttribute("location","UK").addText("James Strachan");
        author1 = rootElement.addElement("author").addAttribute("name","James").addAttribute("location","UK").addText("James Strachan");

        //for deleting node
        testNode.detach();

        try{
            FileWriter out = new FileWriter("foo.xml");
            //OutputFormat outformat =OutputFormat.createCompactFormat();
            OutputFormat outformat = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(out, outformat);
            writer.write(document);
            System.out.println(document.getXMLEncoding());
            writer.close ();
        }
        catch(Exception e){
            e.printStackTrace();
        }

Reply via email to