Solved

Adding a parent node to an existing DOM Document

Posted on 2009-04-07
2
769 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now