java - Error importing XML file into MS Project -


i have programmatically created xml file in java jdom2 library. when try import file ms project, error (we're sorry seems ther problem in file doesn't allow open. try use backup if available)

but when copy content of xml file, in new file , save xml, when try import in project works perfectly.

why possible, , how can solve it?

edit: put code

        element e = new element("project");         document doc = new document(e);          e.addcontent(new element("saveversion").settext("14"));         e.addcontent(new element("name").settext(nomfichero));         e.addcontent(new element("creationdate").settext(fecha));         e.addcontent(new element("lastsaved").settext(fecha2));         e.addcontent(new element("schedulefromstart").settext("1"));         e.addcontent(new element("startdate").settext(fecha));         e.addcontent(new element("finishdate").settext(fecha));         e.addcontent(new element("fystartdate").settext("1"));         e.addcontent(new element("criticalslacklimit").settext("0"));          xmloutputter xmloutput = new xmloutputter();         xmloutput.setformat(format.getprettyformat());         xmloutput.output(doc, new filewriter(file)); 

maybe file encoding issue - 2 files (one generated , 1 created manually) have different encoding. first 1 incorrect , second 1 correct.

if that's case, should generate file right encoding. try:

xmloutput.output(doc, new outputstreamwriter(new fileoutputstream(file), "iso-8859-1")); 

of course should use encoding suits needs (perhaps charset.defaultcharset() work).


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -