This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Writing new line character in DOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Writing new line character in DOM" Watch "Writing new line character in DOM" New topic
Author

Writing new line character in DOM

Luqman Qaiser
Greenhorn

Joined: Aug 21, 2005
Posts: 18
Hi,
How to write a new line character after any node in DOM.

for e.g.
if the DOM structure is
<ROOT>
<FIRSTNAME>Mahesh</FIRSTNAME><LASTNAME>Kumar</LASTNAME>
</ROOT>

How to change it to this below form

<ROOT>
<FIRSTNAME>Mahesh</FIRSTNAME>
<LASTNAME>Kumar</LASTNAME>
</ROOT>

Thanks,
Lucky
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12998
    
    5
How to write a new line character after any node in DOM.

As far as XML is concerned, what you are talking about is a Node of type TEXT_NODE that has a content of a newline character sequence.
In your example, it would be a child of the ROOT element.

Incidently, you should go change your name to fit the JavaRanch name policy.
Bill
Luqman Qaiser
Greenhorn

Joined: Aug 21, 2005
Posts: 18
I have tried exactly what u suggested, But not working...

Kindly Help.
Dave Lenton
Ranch Hand

Joined: Jan 20, 2005
Posts: 1241
Here is everything one will ever want to know about whitespace in XSLT, even the sickest of questions that one can come up with in the most depraved of ones XSLT-whitespace related fantasies.


There will be glitches in my transition from being a saloon bar sage to a world statesman. - Tony Banks
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Writing new line character in DOM
 
It's not a secret anymore!