Solved

Adding a parent node to an existing DOM Document

Posted on 2009-04-07
2
777 Views
Last Modified: 2013-11-23
Hello, I used Oracle XSU (XML SQL Utility) to generate xml. This returns DOM tree as a file type org.w3c.dom.Document, and I'm trying to add a parent node or parent tag on this existing Dom Document using Java. Please see the code for the example. Thank you in advance.
//I have dom object tree as following
Document domDoc = qry.getXMLDOM();
//This gives me something like
/*
<?xml version='1.0'?>
<ROWSET>
  <ROW num="1">
    <EMPNO>7369</EMPNO>
    <ENAME>Smith</ENAME>
    <JOB>CLERK</JOB>
    <MGR>7902</MGR>
    <HIREDATE>12/17/1980 0:0:0</HIREDATE>
    <SAL>800</SAL>
    <DEPTNO>20</DEPTNO>
  </ROW>
  <!-- additional rows ... -->
</ROWSET>
*/
// How do I put a parent tag <REPORT> so it looks like 
/*
<?xml version='1.0'?>
<REPORT>
<ROWSET>
  <ROW num="1">
    <EMPNO>7369</EMPNO>
    <ENAME>Smith</ENAME>
    <JOB>CLERK</JOB>
    <MGR>7902</MGR>
    <HIREDATE>12/17/1980 0:0:0</HIREDATE>
    <SAL>800</SAL>
    <DEPTNO>20</DEPTNO>
  </ROW>
  <!-- additional rows ... -->
</ROWSET>
</REPORT>
*/

Open in new window

0
Comment
Question by:Cheldon
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 24095803
the following shows how to insert a new root into your dom document
http://helpdesk.objects.com.au/java/how-to-insert-new-root-node-in-xml-dom-document

0
 
LVL 1

Author Closing Comment

by:Cheldon
ID: 31568093
This is exactly what I needed. Thank you.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
github account with ecipse 1 47
Java JRE greater than 1.6 5 62
servlet doXXX methods 3 49
Tomcat: Unable to run tomcat service. 2 19
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question