File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML question

 
John Ip
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the org.w3c.dom comes with the J2SDK.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the XML document file with a text editor, are the line breaks there?
Bill
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic