Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 791
  • Last Modified:

Adding a parent node to an existing DOM Document

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
Cheldon
Asked:
Cheldon
1 Solution
 
objectsCommented:
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
 
CheldonAuthor Commented:
This is exactly what I needed. Thank you.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now