DOM hierarchy will not be saved to the file

For the experienced:

I try to write a class in java to create an XML using Dom I use JDeveloper 11.1.1.3. The class seems OK to me, update without problem and runs without error. But in the created file contains only one line which is the xml declaration:

< pre >
& lt;? XML version = "1.0" encoding = "UTF-8" standalone = 'no '? >
< / pre >
I was expecting the DOM tree must also be saved in the file. but it's not. The source code for the class is added as follows. Can anyone spot the problem?

Thank you very much for help!


Newman


< pre >




package testing;

import java.io.File;

Import javax.xml.parsers.DocumentBuilder;
Import javax.xml.parsers.DocumentBuilderFactory;
Import javax.xml.parsers.ParserConfigurationException;

Import javax.xml.transform.Transformer;
Import javax.xml.transform.TransformerException;
Import javax.xml.transform.TransformerFactory;

Import javax.xml.transform.dom.DOMSource;

Import javax.xml.transform.stream.StreamResult;

Import org.w3c.dom.Attr;
to import org.W3C.DOM.document;
Import org.w3c.dom.Element;

public class WriteXMLFile {}
Public Shared Sub main (String [] args) {}
try {}
DocFactory DocumentBuilderFactory = DocumentBuilderFactory.newInstance ();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder ();

root element
Doc document = docBuilder.newDocument ();
Element rootElement = doc.createElement ('company');
doc.appendChild (rootElement);

element of staff
Element staff = doc.createElement ("Staff");
rootElement.appendChild (staff);

Set the attribute to the personal element
Attr attr = doc.createAttribute ("id");
attr.setValue("1");
staff.setAttributeNode (attr);

name element
Element firstname = doc.createElement ("firstname");
firstname.appendChild (doc.createTextNode ("yong"));

LastName element
Element lastname = doc.createElement ("lastname");
lastname.appendChild (doc.createTextNode ("mook kim"));
staff.appendChild (lastname);

Pseudo element
Pseudo element = doc.createElement ("nickname");
nickname.appendChild (doc.createTextNode ("mkyong"));
staff.appendChild (nickname);

part of salary
Element salary = doc.createElement ("salary").
salary.appendChild (doc.createTextNode("100000"));
staff.appendChild (salary);

write the content in the xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance ();
Transformer transformer = transformerFactory.newTransformer ();
DOMSource source = new DOMSource();
File outputFile = new File("c:/apps11113/XMLTesting/testing.xml");
StreamResult result = new StreamResult (outputFile);
transform. Transform (source, result);

} catch (ParserConfigurationException pce) {}
pce.printStackTrace ();
} catch (TransformerException tfe) {}
tfe.printStackTrace ();
}
}
}
< / pre >

Hello

Can anyone spot the problem?

Yes, I think:

DOMSource source = new DOMSource();

Who builds a source empty. Try this instead:

DOMSource source = new DOMSource(doc);

Tags: Oracle Development

Similar Questions

  • SE message: changes made to this photo has not been saved. The file may be read-only or you are not allowed to check-in at the location of the photo, trying to crop an image, or mount it

    Original title: photos

    If I try to crop a photo or repair, it has a message of: changes made to this photo has not been saved. The file may be read-only or you may not save to the location of the image.

    They worked very well the other day, what's past?

    Hi boneyardwolf,

    1. where are the photos?

    2. you have any third-party photo editing software?

    3. what type of files you want to change?

    You can check the following link and try the steps suggested by Marilyn - Support Engineer Moderator Wednesday, March 4, 2009 04:47 and see if it helps to solve the problem

    http://social.answers.Microsoft.com/forums/en-us/vistapictures/thread/9f6bf1f8-50EC-4baa-b2c5-212c823ded68

    Hope this information is useful.

    Jeremy K
    Microsoft Answers Support Engineer
    Visit ourMicrosoft answers feedback Forum and let us know what you think.

    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Word 2007 your AutoCorrect, MSO1033.acl, file could not be saved. The file may be read-only, or you do not have permission to modify the file.

    To get this message when opening Word 2007.

    Your AutoCorrect file, (Japanese weird character? with) MSO1033.acl, could not be saved. The file may be read-only, or you do not have permission to modify the file.

    ALSO when I try to close or save a Word 2007 I get this message:

    Word cannot save or create this file. Make sure that the disk you want to save the file on is not full, write-protected, or damaged. (C:\Program Files\... Normal.dotm)

    I then click on Cancel to not save the changes and then get the following message appears:

    Changes have been made that affect the model overall, Normal. You want to save these changes?

    I click No. in addition to this I'm currently not able to print from word 2007 older that I created a few months before this problem started

    I studied that went through all the troubleshooting steps suggested Microsoft to resolve this issue, but have had no luck... any other help or suggestions would be appreciated. I'm not

    Thank you!!
    Frustrated in minutes

    Install the fixit from article KB2258121 (fixit #50461).

    Although this problem is not mentioned in the KB problem, the fixit indeed solves this problem.

  • Vista will not display description of the file on mouse over. File name, Type, size, and Date modified see the upward, but no description.

    Vista will not display description of the file on mouse over. When I mouse over, a pop-up window displays showing: file name, Type, size and Date of change, however, it does not show the description of the file.

    So, for example if I have 5 files on different types of screw - the description tells me that the size of the screws. IE. 1.5 mm or 1. 8 mm.

    Update: try to get the description of the file displayed messing around in the file properties, now out of 10 records, only 2 includes the name of the file in the mice on the pop-up window. So now what lack us, it's the file name and the Description file.
    Help, please...

    Description of the file in as long as this is not one of the available variables, which can be shown with ToolTips - but there are others who could easily serve the same purpose. Here are the options:

    Consulted
    Attributes
    Created
    DocAuthor
    DocComments
    DocSubject
    DocTitle
    Modified
    Name
    Size
    Type
    To write

    Here is an article on how to change what is shown. http://www.ghacks.net/2008/02/10/customize-windows-explorer-tooltips/ . It is to change the registry, make sure you so first back it up before doing anything so that you can recover in case you make a mistake (or do the right thing, but it does not work as expected). http://www.instant-registry-fixes.org/how-to-backup-windows-vista-registry/ .

    I hope this helps.

    Good luck! Lorien - MCSA/MCSE/network + / A +.

  • Document will not be saved after the page rotation

    After that I turn a page, it will not save it.  I have a hunch, it's safety because the latter document leave a military installation, but it let me extract pages.  I don't understand. I moved the file copied in different places...

    You probably change the display option, which is temporary and cannot be

    has saved. You need to rotate the real pages if you want that it stick.

  • Any ideas why my XPS Viewer will not open saved by the XPS doc?

    I can't open the saved XPS files after my computer recently crashed.

    Hello

    What is the error when you try to open any xps file? XPS Viewer is installed with the .NET Framework 3.0, see (http://windows.microsoft.com/en-AU/windows-vista/What-is-the-XPS-Viewer) to check if it's installed or download from (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=10cc340b-f857-4a14-83f5-25634c3bf043&displaylang=en).

    I hope this helps.

  • virus reinstalled silver CIP removed Windows 7 now, it will not open all of the files to delete or restore and usually I would just shoot what can I do?

    Cannot download all programs from windows to reformat and im yet to have been completely Formate of my readers

    Boot from the Windows 7 DVD

    Click Install now

    Accept the license agreement

    When the option is displayed to select a type of installation, click (Custom advanced)

    Click on drive Options

    Select the disc/s click on Delete

    Click new

    Click on apply

    Click OK

    Click Format, and then click next to proceed with the installation

  • why I can't take a new picture and I can't remove all the images of photos.new will not be saved

    why I can't take a new picture and I can't remove all the images of photos.new will not be saved

    Check your storage space on your iPhone, iPad and iPod touch - Apple Support

  • Receive the error message "you have been connected with a temporary profile, in this profile, you can access saved files and something new created or added to this profile will not be saved"

    Original title: temporary profile

    I was wondering if anyone can help... I have a compaq laptop, windows 8 and the last few times ive turned on n signed in its took much longer than usual and connect to a temporary profile where it seems that everything I had there before such as files and photos have already disappeared. But it then opens with a message saying something along the lines of. . "You have been logged on with a temporary profile, in this profile, you can access saved files and any new tjing created or added to this profile will not be saved" does anyone know how solve this...

    Hi Lucie,.

    Activation of the built-in Administrator account can help get the problem solved.

    Perform the steps suggested by Pinaki displayed from the link below and see if it helps.

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-system/Windows-8-keeps-loading-with-temporary-profile/583abee6-645D-42a1-88da-063547c6eea0

    Answer please if you have any questions.

  • try to change the text in a saved file, but it will not allow isolate me the text, place the cursor in the text box or simply go back to remove.

    try to change the text in a saved file, but it will not allow isolate me the text, place the cursor in the text box or simply go back to remove.

    Hello

    in what format save you your file? If it's a jpg file, then the text is compressed and unfortunately PS is telling things as they are. Even if you could change the text before you save, after having been saved in jpg format, the text is merged and is no longer editable.

    A good solution is to save the files as PSD files, photoshop files. In this case, all layers are saved uncompressed and so your text will appear in its own layer in photoshop. All you need to do in this case to change it is the result of a three-step procedure

    (1) select the right layer

    (2) take the text tool in the tools bar

    (3) mark and change your text

    So the crucial question is: in what format you save your file?

  • error message "coordinates would not be saved" when the contact info is correct.

    original title: error message

    "contact information could not be saved" when the contact info is correct.  Happens all the time on this computer

    You will need to create a new post on the Windows Live support for assistance site: http://windowslivehelp.com/forums.aspx?forumid=28aff142-9106-4d74-be08-9b5d9fc0efea

  • VMDK not getting saved by the VCBackup for VMS V7

    Hello

    We did an upgrade to VI3 to vSphere4 a couple of weeks.

    This week, I created a few new virtual machines that are now 7 vms.

    These virtual machines are running much and have no problems.

    Only downside, it's that we are more able to creat VCBackups of these machines V7, because the VMDK will not be saved.

    The only files get saved are .log, .vmx, .vram and. Bah

    Here's what VCbackup connects:

    Current working directory: D:\Jobs\VCBBackup

    HOSTINFO: See Intel CPU, numCoresPerCPU 4, numThreadsPerCore 1.

    HOSTINFO: This machine has 4 cores total, 1 physical CPU and 4 logical processors.

    Using the libcrypto, version 90709F

    Copy "BERVM09A16/BERVM09A16.vmx [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16/BERVM09A16.nvram [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-7.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-2.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-3.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-4.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-5.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware-6.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    Copy "BERVM09A16//vmware.log [_CX_Oracle_02]:

    +        0%=====================50%=====================100%+

    +        **************************************************+

    We use this command to start the backup:

    vcbmounter.exe h vcenter.ourcompany.local u Pei ultrasecurepassword - a name: % 1 - fullvm 'E:\VCBBACKUP\TODAY\%DATE%_%1' of backup-L t r 2 & gt; D:\Jobs\VCBBackup\VCBLog\%date%\%1.txt

    Old virtual machines are getting backed up without any problem.

    You have any suggestions?

    Kind regards

    John

    Hello.

    You use the latest version of VCB, i.e. 1.5 U1?

    Good luck!

  • Not be saved in the data base of page elements

    Good afternoon

    I hope that it is a return of holiday brain cramp but I don't see the problem... I'm working on a help desk application and when a closed ticket is displayed, a button to reopen ticket. When the button is clicked: P5_STATUS_CODE should be replaced by reopened; P5_CLOSED_BY_KEY & P5_CLOSED_DATE must be null. the record must be recorded and the page redirected on itself.

    I've created a submit after process (sequence 10) that updates the fields with a condition that it triggers when the button reopen ticket (APPLY_CHANGES).

    Start
    : P5_STATUS_CODE: = 'reopened ';
    : P5_CLOSED_BY_KEY: = null;
    : P5_CLOSED_DATE: = null;

    wwv_flow. Debug ("P5_STATUS_CODE value = ' |: p5_status_code");
    end;

    Because the button to reopen ticket has a REQUEST of APPLY_CHANGES type, it triggers the process of update DML (sequence 30). Then the branches page on itself.

    Looking at the record in the database, I see that the date of modification (engine database trigger) is correct but the status code and closed fields were not updated.

    When I run the form with debugging, the process works and by the debug statement, the value of P5_STATUS_CODE is replaced by Reopened. Then the process of the DML is run. And finally the branch runs.

    0.02: point of treatment: ON_SUBMIT_BEFORE_COMPUTATION
    0.02: branch point: BEFORE_COMPUTATION
    0.02: point of calculation: AFTER_SUBMIT
    0.02: tabs: make the connection for the tab queries
    0.02: branch point: BEFORE_VALIDATION
    0.02: perform validations:
    0.02:... Point Not Null Validation: P5_SITE_KEY
    0.02:... Point Not Null Validation: P5_PEOPLE_KEY
    0.02:... Point Not Null Validation: P5_TRACKER_KEY
    0.02:... Point Not Null Validation: P5_ASSIGNED_TO_KEY
    0.02: branch point: BEFORE_PROCESSING
    0.02: point of treatment: AFTER_SUBMIT
    0.02:... Process of "reopenTicket": begin PLSQL (AFTER_SUBMIT): P5_STATUS_CODE: = 'Reopened '; : P5_CLOSED_BY_KEY: = null; : P5_CLOSED_DATE: = null; wwv_flow. Debug ("P5_STATUS_CODE value = ' |: p5_status_code"); end;
    0.03: P5_STATUS_CODE value = Reopened
    0.03:... Treat "process line of the POST": DML_PROCESS_ROW (AFTER_SUBMIT) #OWNER #:TICKET:P5_KEY:KEY | IUD
    0.04:... Do not run the "reset page" process, treat the point = AFTER_SUBMIT, condition type =, when you press the button = DELETE
    0.04: branch point: AFTER_PROCESSING
    0.04:... Leadership assessment: AFTER_PROCESSING Type: button 'REDIRECT_URL': Branch (key no.): ASK
    0.04:... Leadership assessment: AFTER_PROCESSING Type: button 'REDIRECT_URL': 1820524144021869 branch: (Unconditional)

    I tried to change the source used on the fields still only reach and that didn't work either. Does anyone have a hypothesis as to why the fields I'm reset are not saved?

    Thank you
    Ray

    If the box is not displayed then the items are not part of the subject page and will not be part of the automatic DML. Try creating another process sequenced after the automatic DML. This process must be a simple update statement updating these columns in your table.

  • iPhone will not be displayed in the finder

    I'm trying to move some of the photos from my phone to a file on my computer and my phone will not be displayed in the tab "currencies" in the finder. It's an iPhone 6 and it is connected through the USB port. I know this isn't an error connection because when I plug it in it costs and is trying to import my photos in the section 'photos' from my computer. I went into the settings in the finder and all turned on and it will not always be displayed. Why is this?

    Because Apple has decided that OS X is smarter than you and me. They removed this option on the latest versions of Mac OS X (my devices do not appear more, grrrr...). Try instead to use Image Capture and import or remove photos from there.

  • Apple os 9.3.3 charged down behind my back and now my i phone will not open most of the apps because there is not enough memory.  I see that I have 40 GB of memory left on the cloud over 50.  Question, how can I use my pc to see what has been done

    Apple os 9.3.3 charged down behind my back and now my i phone will not open most of the apps because there is not enough memory.  I see that I have 40 GB of memory left on the cloud over 50.  How can question, I use my pc to see what has been downloaded on the cloud?

    Your question has nothing to do with iCloud. You should remove unnecessary data from your phone to free up about 10% of your phone's storage space.

Maybe you are looking for