This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I am trying to read the XML file using the DOM Parser and one of the lines in that XML file has value with new line characters i.e \n. Now when i try to write the data retrieved i.e. the line with the new line character in the text area then the new line character is appearing as it is. i.e. instead of printing the text appearing after \n in a new line it is printing \n followed by the text in the same line. For eg. If the text read from XML file is "Please write this to a \n new line." The result expected in the text area would be Please write this to a new line. But the result that I am getting is Please write this to a \n new line. The same thing if I hard code in a String variable and setText of the textarea with this hard coded value it is giving expected result i.e. Please write this to a new line. Thanks a lot. Shweta
\n is an escape sequence in java source code and is translated at compile time to the corresponding character as defined by the synctactic rules of java. XML has its own syntactic rules, which are totally independent of the ones of java. After all, you want to have XML files be handled identically regardless of the programming language used to parse it. So you have to use the XML rules to insert the newline character.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus