aspose file tools*
The moose likes XML and Related Technologies and the fly likes Adding a carriage return to a Node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Adding a carriage return to a Node" Watch "Adding a carriage return to a Node" New topic
Author

Adding a carriage return to a Node

Francesco Marchioni
author
Ranch Hand

Joined: Sep 22, 2003
Posts: 190
Hi all,
I'm in the process of manipulating an XML file using DOM Api.
Somewhere I have to copy Nodes from one part of the XML
to another part.
I'm using insertBefore method to insert a Node as first child of the parent Node.
The problem is that after the node is inserted, the carriage return is missing.
I'd like to insert a carriage return immediately after.
How can I accomplish it ?
Thanks a lot
Francesco


WildFly 8 Administration Book - JBoss Tutorials
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
What you see as a carriage return in the XML document is actually a Node of the TEXT_NODE type with a nodeValue of "\r\n". You will have to create and add this Node separately.
Formatted XML documents are FULL of text nodes that are not immediately obvious - thats why getFirstChild() may not return what you expected.
Bill


Java Resources at www.wbrogden.com
 
Don't get me started about those stupid light bulbs.
 
subject: Adding a carriage return to a Node
 
Similar Threads
Trouble with a toy tree [SOLVED]
problem with inserting formatted text
ParserImpl for DOM
Binary Search Tree
carriage return characters