Solved

Java, HTML and XML

Posted on 2003-12-05
5
222 Views
Last Modified: 2013-11-24
I have web application which contains a questionnaire which users fill in and submit.  

The questionnaire is generated by a Java servlet using an XML File for the structure.  

When the user clicks on 'edit questionnaire', the java servlet is called.  The servlet retrieves the XML files and reads the file into a vector.  It then manipulates the vector to produce the the HTML questionnaire in edit mode for the user to complete.

Now here is where I am having trouble.  On the questionnaire in edit mode is a number of textarea fields.  If the user places a character return in the field to created a new line and saves the form, I need to capture this and place '<br>' in it place otherwise my XML file becomes invaid  and it places the node values over two line which knocks all my code out.

e.g

Should be:  <node1>myvalue<br>myvalue2</node1>

Currently: <node1>myvalue
                        myvalues2</node1>

Does anybody know how I can capture the character return in a textarea field and replace it with the '<br>' value?

Thanks in advance.
0
Comment
Question by:fayeb
  • 3
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
s.replaceAll("\n", "<br>");
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Have you thought of using XSL to generate the HTML from the XML?
0
 
LVL 3

Expert Comment

by:applekanna
Comment Utility
this is not exactly your solution but the problem and solution idea here is the same

http://oldlook-search.experts-exchange.com/Web/Web_Languages/JSP/Q_20791591.html
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
If that node can contain a line break, it must be <br /> as <br> would not be well-formed XML.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now