Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 12769
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Writing new line character in DOM