Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Write a Node object to a XML file

 
Saurabh Joshi
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying hands on DOM API for the first time.

I am in a fix.
My aim is to delete some of the parent tags from one XML file and bring all the child tags to another XML file.
e.g.


I want to remove & and take <c></c> and write to a XML file. <c> has more children under it.

I am trying to implement an approach where I am doing the following -


Now I want to write copyofGetXYZ Node to a XML file.
I am unable to find relevant API to do this.

Kindly suggest the right path.

Thanking you in anticipation.

Regards,
Saurabh.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going to need a separate Document to hold the Node you are moving.

Search for "Harold processing xml with java" to find the free online book which covers all this sort of thing with excellent tutorials.

Bill
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saurabh Joshi wrote:Hi,

I am trying hands on DOM API for the first time.


indeed. I would just use XSLT to do that.
 
Saurabh Joshi
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello William & Paul,

Actually I just figured out the way to do that....


So DOMSource constructor gives us that facility.

Thanks Williams for that book info., it will be a great help further.
Paul, I will surely explore your suggestion and if that's fits the design I will adopt it.

Regards,
Saurabh.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it does. And you don't even need to make a copy of the node to give to the transformer. Just find the node in your DOM and pass that to the transformer.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic