• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

XML question

 
Ranch Hand
Posts: 45
  • 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
 
Rancher
Posts: 43016
76
  • 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?
 
author and deputy
Posts: 3150
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the org.w3c.dom comes with the J2SDK.
 
Author and all-around good cowpoke
Posts: 13078
6
  • 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
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic