File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML question" Watch "XML question" New topic
Author

XML question

John Ip
Ranch Hand

Joined: Mar 04, 2004
Posts: 45
Hi all,

I am writing a xml file writer to write an xml file and store it in the file system. And I have another xml file reader to read the xml file. I have the following situation.

I add a Text node into the DOM and the value is a string (eg. "First Thing\r\nYou need to do this\r\nSecond\r\nYou need to do that" )with new line characters "\r\n". I replaced all the "\r\n" with "\n". And I assign the string to the value of the text node. I use text.getNodeValue() to confirm the value I put into the text node is "First Thing\nYou need to do this\nSecond\nYou need to do that". It prints out as I expected.

However, when I read the xml file with my xml file reader program, all the "\n" characters gone....... I use text.getNodeValue().. and i get "First Thing You need to do this Second You need to do that". Why is that? Can any one give me a clue?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
What about the file that is written to disk? Does it have the newlines? What library do you use to read and write the file?
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi John,
The section is for question related to webservices, I am moving your post to our XML and related technologies forum for better visibility.
Regards
Balaji
John Ip
Ranch Hand

Joined: Mar 04, 2004
Posts: 45
I am using the org.w3c.dom comes with the J2SDK.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
If you look at the XML document file with a text editor, are the line breaks there?
Bill
 
wood burning stoves
 
subject: XML question