Solved

Adding a parent node to an existing DOM Document

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Free Alternative to JIRA 4 91
Grunt No Clean Targets 6 109
micro services spring boot application error 3 148
replace a word with other 1 40
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 …
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

867 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

16 Experts available now in Live!

Get 1:1 Help Now