Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Put a node into a new xml document

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a node like this:

<A a="a" b="b">
<B c="c"/>
<C d="d"/>
</A>

I need to write this entire node into a new xml document in the placeholder as follows:

<xml prologue>
<X>
<!-- place for the above node -->
</X>

I am using DOM as the parser. Any ideas on how this can be done.
I tried using root.importNode(), however, it appends only
<A a="a" b="b"> and misses the rest of the child nodes.

Plez help!!!
 
Hasan Pasha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the following method in the Node Interface (org.w3c.dom)



API documentation:
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic